|
|
@@ -4,7 +4,7 @@
|
|
|
* @license WTFPL
|
|
|
* @url http://ranides.net/projects/???
|
|
|
*/
|
|
|
-package net.ranides.assira.collection.mockup;
|
|
|
+package net.ranides.assira.test;
|
|
|
|
|
|
import java.util.AbstractMap;
|
|
|
import java.util.ArrayList;
|
|
|
@@ -56,18 +56,6 @@ public abstract class TMap<K,V> {
|
|
|
return new AbstractMap.SimpleImmutableEntry<>(key, value);
|
|
|
}
|
|
|
|
|
|
- public TItem<K,V> next() {
|
|
|
- return new TItem<>(that, that.nextKey(key), that.nextValue(value));
|
|
|
- }
|
|
|
-
|
|
|
- public TItem<K,V> next(int count) {
|
|
|
- TItem<K,V> item = this;
|
|
|
- for(int i=0; i<count; i++) {
|
|
|
- item = item.next();
|
|
|
- }
|
|
|
- return item;
|
|
|
- }
|
|
|
-
|
|
|
public Map<K,V> into(Map<K,V> target) {
|
|
|
target.put(key(), value());
|
|
|
return target;
|
|
|
@@ -126,18 +114,6 @@ public abstract class TMap<K,V> {
|
|
|
return array;
|
|
|
}
|
|
|
|
|
|
- public TItems<K,V> next() {
|
|
|
- return next(1);
|
|
|
- }
|
|
|
-
|
|
|
- public TItems<K,V> next(int count) {
|
|
|
- TItems<K,V> items = new TItems<K,V>(that);
|
|
|
- for(int i=0, n=data.size(); i<n; i++) {
|
|
|
- items.data.add(data.get(i).next(count));
|
|
|
- }
|
|
|
- return items;
|
|
|
- }
|
|
|
-
|
|
|
public TItems<K,V> sort(Comparator<K> cmp) {
|
|
|
TItems<K,V> items = new TItems<>(that);
|
|
|
items.data.addAll(data);
|
|
|
@@ -162,24 +138,16 @@ public abstract class TMap<K,V> {
|
|
|
data.set(bi, a);
|
|
|
}
|
|
|
|
|
|
- public TItems<K,V> item(TItem<K,V> item) {
|
|
|
- data.add(item);
|
|
|
- return this;
|
|
|
- }
|
|
|
+ public TItems<K,V> item(int item) {
|
|
|
+ data.add(that.item(item,0));
|
|
|
+ return this;
|
|
|
+ }
|
|
|
|
|
|
- public TItems<K,V> item(TItems<K,V> items) {
|
|
|
- data.addAll(items.data);
|
|
|
- return this;
|
|
|
- }
|
|
|
-
|
|
|
- public TItems<K,V> item(int item) {
|
|
|
- return TItems.this.item(that.item(item));
|
|
|
+ public TItems<K,V> item(int item, int n) {
|
|
|
+ data.add(that.item(item,n));
|
|
|
+ return this;
|
|
|
}
|
|
|
|
|
|
- public TItems<K,V> item(int item, int next) {
|
|
|
- return TItems.this.item(that.item(item).next(next));
|
|
|
- }
|
|
|
-
|
|
|
@Override
|
|
|
public Iterator<TItem<K,V>> iterator() {
|
|
|
return data.iterator();
|
|
|
@@ -205,20 +173,24 @@ public abstract class TMap<K,V> {
|
|
|
|
|
|
}
|
|
|
|
|
|
- protected abstract K key(int index);
|
|
|
+ protected abstract K key(int index, int n);
|
|
|
|
|
|
- protected abstract V value(int index);
|
|
|
+ protected abstract V value(int index, int n);
|
|
|
|
|
|
- protected abstract K nextKey(K key);
|
|
|
+ protected K key(int index) {
|
|
|
+ return key(index, 0);
|
|
|
+ }
|
|
|
|
|
|
- protected abstract V nextValue(V value);
|
|
|
+ protected V value(int index) {
|
|
|
+ return value(index, 0);
|
|
|
+ }
|
|
|
|
|
|
public TItem<K,V> item(int index) {
|
|
|
- return new TItem<>(this, key(index), value(index));
|
|
|
+ return item(index, 0);
|
|
|
}
|
|
|
-
|
|
|
- public TItem<K,V> item(int index, int next) {
|
|
|
- return item(index).next(next);
|
|
|
+
|
|
|
+ public TItem<K,V> item(int index, int n) {
|
|
|
+ return new TItem<>(this, key(index, n), value(index, n));
|
|
|
}
|
|
|
|
|
|
public TItems<K,V> list(int... indexes) {
|
|
|
@@ -240,14 +212,19 @@ public abstract class TMap<K,V> {
|
|
|
public TItems<K,V> range(int count) {
|
|
|
return range(0,count);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public TItems<K,V> urange(int begin, int end) {
|
|
|
- TItems<K,V> items = range(begin, end);
|
|
|
- return new TItems<>(this).item(items).item(items).item(items.next()).shuffle(777);
|
|
|
+ TItems<K,V> ret = new TItems<>(this);
|
|
|
+ for(int i=begin; i<end; i++) {
|
|
|
+ ret.data.add(item(i,0));
|
|
|
+ ret.data.add(item(i,0));
|
|
|
+ ret.data.add(item(i,1));
|
|
|
+ }
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+
|
|
|
+ public TItems<K,V> urange(int count) {
|
|
|
+ return urange(0,count);
|
|
|
}
|
|
|
-
|
|
|
- public TItems<K,V> urange(int count) {
|
|
|
- return urange(0,count);
|
|
|
- }
|
|
|
|
|
|
}
|