diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-01-23 10:28:14 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-01-23 10:28:14 +0100 |
commit | bb729c2c6d137ae6f529f4db514ee84ed691f71e (patch) | |
tree | fcaa21e4cf22f673cc9180ce7b5a13f614399077 /src/datastructures/linkedlists | |
parent | add array linked lists (diff) | |
download | algorithms-and-data-structures-bb729c2c6d137ae6f529f4db514ee84ed691f71e.tar.gz algorithms-and-data-structures-bb729c2c6d137ae6f529f4db514ee84ed691f71e.tar.bz2 algorithms-and-data-structures-bb729c2c6d137ae6f529f4db514ee84ed691f71e.tar.xz |
whoops
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r-- | src/datastructures/linkedlists/array-template | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/datastructures/linkedlists/array-template b/src/datastructures/linkedlists/array-template index 5fce858..bee7e01 100644 --- a/src/datastructures/linkedlists/array-template +++ b/src/datastructures/linkedlists/array-template @@ -53,11 +53,11 @@ public class £{name}<T> /* Most be a power of 2 */ if ((initialCapacity & initialCapacity - 1) != 0) { - initialCapacity >>= 1; - initialCapacity >>= 2; - initialCapacity >>= 4; - initialCapacity >>= 8; - initialCapacity >>= 16; + initialCapacity |= initialCapacity >> 1; + initialCapacity |= initialCapacity >> 2; + initialCapacity |= initialCapacity >> 4; + initialCapacity |= initialCapacity >> 8; + initialCapacity |= initialCapacity >> 16; initialCapacity++; } @@ -148,11 +148,11 @@ public class £{name}<T> int cap = size; if ((cap & cap - 1) != 0) { - cap >>= 1; - cap >>= 2; - cap >>= 4; - cap >>= 8; - cap >>= 16; + cap |= cap >> 1; + cap |= cap >> 2; + cap |= cap >> 4; + cap |= cap >> 8; + cap |= cap >> 16; cap++; } @@ -213,7 +213,7 @@ public class £{name}<T> return this.reusable[--this.reuseHead]; if (this.end == this.capacity) { - this.capacity >>= 1; + this.capacity <<= 1; System.arraycopy(this.values, 0, this.values = (T[])(new Object[this.capacity]), 0, this.end); System.arraycopy(this.reusable, 0, this.reusable = new int[this.capacity], 0, this.end); System.arraycopy(this.next, 0, this.next = new int[this.capacity], 0, this.end); |