gitweb on Svarog
projekti pod git sistemom za održavanje verzija -- projects under the git version control system
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0668b51)
raw | patch | inline | side by side (parent: 0668b51)
author | Doni Pracner <quinnuendo@gmail.com> | |
Sun, 8 Nov 2015 14:19:46 +0000 (15:19 +0100) | ||
committer | Doni Pracner <quinnuendo@gmail.com> | |
Sun, 8 Nov 2015 14:26:38 +0000 (15:26 +0100) |
Hash/Gadjanje.java | patch | blob | history | |
Hash/Kancelarija.java | patch | blob | history |
diff --git a/Hash/Gadjanje.java b/Hash/Gadjanje.java
index 364c495dfedc17d4832f1012caf0ffe191a46e95..27684ec253d543a87ead7edc355434e363009a87 100644 (file)
--- a/Hash/Gadjanje.java
+++ b/Hash/Gadjanje.java
if (rezultati != null && o2.rezultati != null) {
if (o2.rezultati.length == rezultati.length) {
for (int i = 0; i < rezultati.length; i++) {
- if (o2.rezultati[i] != rezultati[i]){
+ if (o2.rezultati[i] != rezultati[i]) {
// cim je nesto razlicito nisu isti
return false;
}
@Override
public int hashCode() {
int rez = 0;
- for (int i = 0; i < rezultati.length; i++) {
- rez = (rez + rezultati[i] * (MAX_DUZ + 1 - i)) * 7;
+ if (rezultati != null) {
+ for (int i = 0; i < rezultati.length; i++) {
+ rez = (rez + rezultati[i] * (MAX_DUZ + 1 - i)) * 7;
+ }
}
return rez;
}
diff --git a/Hash/Kancelarija.java b/Hash/Kancelarija.java
index 9447969d471e50d22528492d5f5ece5b388e7d36..6d157b5d639092937f5571aea17a91e4153a720f 100644 (file)
--- a/Hash/Kancelarija.java
+++ b/Hash/Kancelarija.java
}
public int hashCode() {
- return prezime.hashCode() * broj;
+ int rez = 1;
+ if (prezime != null) {
+ rez *= prezime.hashCode();
+ }
+ rez *= broj;
+ return rez;
}
@Override