Skip to content

Commit 5b2d41a

Browse files
committed
Added more meaningful comments on the resizing methods
1 parent dc91922 commit 5b2d41a

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/com/jwetherell/algorithms/data_structures/HashMap.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -184,14 +184,14 @@ private void reduce() {
184184
}
185185

186186
/**
187-
* Increases the input ten-fold
187+
* Increases the input ten-fold. e.g. 16->160
188188
*/
189189
private static final int getLargerSize(int input) {
190190
return input*10;
191191
}
192192

193193
/**
194-
* Reduces the input to a fourth
194+
* Returns one fourth of the input. e.g. 16->4
195195
*/
196196
private static final int getSmallerSize(int input) {
197197
return input/4;
@@ -544,7 +544,7 @@ private void increase() {
544544

545545
// Re-hash old data
546546
for (Pair<K,V> p : temp) {
547-
if (p!=null)
547+
if (p != null)
548548
this.put(p);
549549
}
550550
}
@@ -560,20 +560,20 @@ private void reduce() {
560560

561561
// Re-hash old data
562562
for (Pair<K,V> p : temp) {
563-
if (p!=null)
563+
if (p != null)
564564
this.put(p);
565565
}
566566
}
567567

568568
/**
569-
* Returns double of the input
569+
* Doubles the input. e.g. 16->32
570570
*/
571571
private static final int getLargerSize(int input) {
572572
return input<<1;
573573
}
574574

575575
/**
576-
* Returns one fourth of the input
576+
* Returns one fourth of the input. e.g. 16->8->4
577577
*/
578578
private static final int getSmallerSize(int input) {
579579
return input>>1>>1;

0 commit comments

Comments
 (0)