Skip to content

Commit f02c4ee

Browse files
committed
Add prototype mapbuilder
Prototype map builder may be working Some fixes and optimizations in the new Champ HashmapBuilder Remove commented out code Corrected behavior in MapBuilder for hashcollision nodes Build up the Hashmap's hash, as it is being built Hashmap className is Map, started working on hashmap merge Add alias tracking, releaseFence-ing Cleanup in ChampHashMap Revert changes to mutable.HashMap implementation privacy Update with new keys, even if they ==, if they are not eq Replace Vectors with Arrays in HashMap Fix missing first half in Map.concat Revert changes to classname and Map.newBuilder Remove unused method in ChampHashMapBuilder Rename MapBuilder to HashMapBuilder Avoid recomputing hashes and tuples when concatenating HashMaps Fix array index out of bounds in HashMapBuilder Fix size bug in HashMapBuilder HashMapBuilder returns reused empty when possible Fix broken behavior in HashCollisionMap.updated Some optimizations in HashCollisionNode#updated Fix bug in Hash building in HashMapBuilder Do not clear HashMapBuilder's rootnode if it is empty WIP -- building smart map builder which falls back to hashmapbuilder for larger maps MapBuilderImpl is the newBuilder of Map Remove special casing in hashMapBuilder.addAll for map4 Use newEmptyRootNode in HashMapBuilder rather than reimplementing it Use new Node#removeAnyElement to remove content arrays rather than using generic arrays Replace = null initialization with = _ Make HashMapBuilder private[immutable] HashCollisionMapNodes use Vectors again Remove ClassTag import Fix HashMapBenchmark#concat Revert hanges in SetMapConsistencyTest More property tests and optimizations to HashMapBuilder Remove usesless HashMapTests use bitwise operator assignment where possible in HashMap Replace HashMap builder addAll implementation iwth ChamBaseIterator approach Remove wrongly added .DS_Store Fix implementation of HashMapBuilder#addAll
1 parent 88921eb commit f02c4ee

File tree

3 files changed

+443
-41
lines changed

3 files changed

+443
-41
lines changed

library/src/scala/collection/immutable/ChampCommon.scala

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,15 @@ private[immutable] abstract class Node[T <: Node[T]] {
5858
result
5959
}
6060

61+
protected final def removeAnyElement(as: Array[Any], ix: Int): Array[Any] = {
62+
if (ix < 0) throw new ArrayIndexOutOfBoundsException
63+
if (ix > as.length - 1) throw new ArrayIndexOutOfBoundsException
64+
val result = new Array[Any](as.length - 1)
65+
arraycopy(as, 0, result, 0, ix)
66+
arraycopy(as, ix + 1, result, ix, as.length - ix - 1)
67+
result
68+
}
69+
6170
protected final def insertElement(as: Array[Int], ix: Int, elem: Int): Array[Int] = {
6271
if (ix < 0) throw new ArrayIndexOutOfBoundsException
6372
if (ix > as.length) throw new ArrayIndexOutOfBoundsException
@@ -67,6 +76,15 @@ private[immutable] abstract class Node[T <: Node[T]] {
6776
arraycopy(as, ix, result, ix + 1, as.length - ix)
6877
result
6978
}
79+
protected final def insertAnyElement(as: Array[Any], ix: Int, elem: Int): Array[Any] = {
80+
if (ix < 0) throw new ArrayIndexOutOfBoundsException
81+
if (ix > as.length) throw new ArrayIndexOutOfBoundsException
82+
val result = new Array[Any](as.length + 1)
83+
arraycopy(as, 0, result, 0, ix)
84+
result(ix) = elem
85+
arraycopy(as, ix, result, ix + 1, as.length - ix)
86+
result
87+
}
7088
}
7189

7290
/**

0 commit comments

Comments
 (0)