Skip to content

Commit ad89cb3

Browse files
committed
moves ArrayToMapAdaptor into common package
1 parent cce5cb3 commit ad89cb3

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

src/main/java/org/javimmutable/collections/common/AbstractJImmutableArray.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
import org.javimmutable.collections.JImmutableMap;
4444
import org.javimmutable.collections.MapEntry;
4545
import org.javimmutable.collections.cursors.TransformCursor;
46-
import org.javimmutable.collections.hash.ArrayToMapAdaptor;
4746

4847
import java.util.Iterator;
4948
import java.util.Map;

src/main/java/org/javimmutable/collections/hash/ArrayToMapAdaptor.java renamed to src/main/java/org/javimmutable/collections/common/ArrayToMapAdaptor.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,13 @@
3333
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3434
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3535

36-
package org.javimmutable.collections.hash;
36+
package org.javimmutable.collections.common;
3737

3838
import org.javimmutable.collections.Func1;
3939
import org.javimmutable.collections.Holder;
4040
import org.javimmutable.collections.JImmutableArray;
4141
import org.javimmutable.collections.JImmutableMap;
4242
import org.javimmutable.collections.MapEntry;
43-
import org.javimmutable.collections.common.IteratorAdaptor;
4443
import org.javimmutable.collections.cursors.TransformCursor;
4544

4645
import java.util.AbstractCollection;
@@ -112,7 +111,7 @@ public boolean containsValue(Object o)
112111
@Override
113112
public T get(Object o)
114113
{
115-
return map.find((Integer)o).getValueOrNull();
114+
return map.get((Integer)o);
116115
}
117116

118117
@Override

src/test/java/org/javimmutable/collections/array/trie32/Trie32ArrayTest.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646
import java.util.Arrays;
4747
import java.util.Collections;
4848
import java.util.List;
49+
import java.util.Map;
50+
import java.util.TreeMap;
4951

5052
public class Trie32ArrayTest
5153
extends TestCase
@@ -84,15 +86,19 @@ public void testVarious()
8486
{
8587
List<Integer> indexes = createBranchIndexes();
8688
for (int length = indexes.size(); length > 0; --length) {
89+
Map<Integer, Integer> map = new TreeMap<Integer, Integer>();
8790
List<Integer> keys = new ArrayList<Integer>();
8891
List<Integer> values = new ArrayList<Integer>();
8992
Trie32Array<Integer> array = Trie32Array.of();
9093
for (int i = 0; i < length; ++i) {
91-
array = array.assign(indexes.get(i), i);
92-
keys.add(indexes.get(i));
94+
final Integer index = indexes.get(i);
95+
array = array.assign(index, i);
96+
keys.add(index);
9397
values.add(i);
98+
map.put(index, i);
9499
assertEquals(i + 1, array.size());
95100
}
101+
assertEquals(array.getMap(), map);
96102
StandardCursorTest.listCursorTest(keys, array.keysCursor());
97103
StandardCursorTest.listCursorTest(values, array.valuesCursor());
98104
for (int i = 0; i < length; ++i) {

0 commit comments

Comments
 (0)