|
@@ -9,11 +9,13 @@ package net.ranides.assira.collection.lookups;
|
|
|
|
|
|
|
|
import net.ranides.assira.collection.IntCollection;
|
|
import net.ranides.assira.collection.IntCollection;
|
|
|
import net.ranides.assira.collection.arrays.ArrayAllocator;
|
|
import net.ranides.assira.collection.arrays.ArrayAllocator;
|
|
|
|
|
+import net.ranides.assira.collection.arrays.ArrayUtils;
|
|
|
import net.ranides.assira.collection.arrays.NativeArraySort;
|
|
import net.ranides.assira.collection.arrays.NativeArraySort;
|
|
|
import net.ranides.assira.collection.iterators.IntListIterator;
|
|
import net.ranides.assira.collection.iterators.IntListIterator;
|
|
|
import net.ranides.assira.collection.iterators.RandomAccessIntIterator;
|
|
import net.ranides.assira.collection.iterators.RandomAccessIntIterator;
|
|
|
import net.ranides.assira.collection.iterators.RandomAccessIterator;
|
|
import net.ranides.assira.collection.iterators.RandomAccessIterator;
|
|
|
import net.ranides.assira.collection.lists.AIntList;
|
|
import net.ranides.assira.collection.lists.AIntList;
|
|
|
|
|
+import net.ranides.assira.collection.maps.BlockMap;
|
|
|
import net.ranides.assira.generic.CompareUtils;
|
|
import net.ranides.assira.generic.CompareUtils;
|
|
|
|
|
|
|
|
import java.util.AbstractSet;
|
|
import java.util.AbstractSet;
|
|
@@ -29,7 +31,7 @@ import java.util.SortedMap;
|
|
|
*
|
|
*
|
|
|
* @author Ranides Atterwim {@literal <ranides@gmail.com>}
|
|
* @author Ranides Atterwim {@literal <ranides@gmail.com>}
|
|
|
*/
|
|
*/
|
|
|
-public class ArrayLookup<K> extends ALookup<K> {
|
|
|
|
|
|
|
+public class ArrayLookup<K> extends ALookup<K> implements BlockMap<K,Integer> {
|
|
|
|
|
|
|
|
private static final long serialVersionUID = 1L;
|
|
private static final long serialVersionUID = 1L;
|
|
|
|
|
|
|
@@ -170,6 +172,26 @@ public class ArrayLookup<K> extends ALookup<K> {
|
|
|
array[b] = t;
|
|
array[b] = t;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public int capacity() {
|
|
|
|
|
+ return keys.length;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public boolean trim() {
|
|
|
|
|
+ return trim(keys.length);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public boolean trim(int n) {
|
|
|
|
|
+ if(n > capacity()) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ this.keys = ArrayUtils.slice(keys, 0, n);
|
|
|
|
|
+ this.vars = ArrayUtils.slice(vars, 0, n);
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public Set<LookupEntry<K>> fastEntrySet() {
|
|
public Set<LookupEntry<K>> fastEntrySet() {
|
|
|
return new AbstractSet<LookupEntry<K>>() {
|
|
return new AbstractSet<LookupEntry<K>>() {
|