diff options
Diffstat (limited to 'src/Java/gtPlusPlus/api/objects/data')
-rw-r--r-- | src/Java/gtPlusPlus/api/objects/data/AutoMap.java | 77 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/api/objects/data/Pair.java | 27 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/api/objects/data/Quad.java | 33 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/api/objects/data/Triplet.java | 27 |
4 files changed, 164 insertions, 0 deletions
diff --git a/src/Java/gtPlusPlus/api/objects/data/AutoMap.java b/src/Java/gtPlusPlus/api/objects/data/AutoMap.java new file mode 100644 index 0000000000..a8d24d36d8 --- /dev/null +++ b/src/Java/gtPlusPlus/api/objects/data/AutoMap.java @@ -0,0 +1,77 @@ +package gtPlusPlus.api.objects.data; + +import java.io.Serializable; +import java.util.*; + +public class AutoMap<V> implements Iterable<V>, Cloneable, Serializable { + + /** + * The Internal Map + */ + private Map<Integer, V> mInternalMap = new HashMap<Integer, V>(); + + /** + * The Internal ID + */ + private int mInternalID = 0; + private static final long serialVersionUID = 3771412318075131790L; + + @Override + public Iterator<V> iterator() { + return values().iterator(); + } + + public synchronized boolean setValue(V object){ + int mOriginalID = this.mInternalID; + put(object); + if (this.mInternalMap.get(mOriginalID).equals(object) || mOriginalID > this.mInternalID){ + return true; + } + else { + return false; + } + } + + public synchronized V put(V object){ + return set(object); + } + + public synchronized V set(V object){ + return mInternalMap.put(mInternalID++, object); + } + + public synchronized V get(int id){ + return mInternalMap.get(id); + } + + public synchronized Collection<V> values(){ + return mInternalMap.values(); + } + + public synchronized int size(){ + return mInternalMap.size(); + } + + public synchronized int hashcode(){ + return mInternalMap.hashCode(); + } + + public synchronized boolean containsKey(int key){ + return mInternalMap.containsKey(key); + } + + public synchronized boolean containsValue(V value){ + return mInternalMap.containsValue(value); + } + + public synchronized boolean isEmpty(){ + return mInternalMap.isEmpty(); + } + + public synchronized boolean clear(){ + this.mInternalID = 0; + this.mInternalMap.clear(); + return true; + } + +} diff --git a/src/Java/gtPlusPlus/api/objects/data/Pair.java b/src/Java/gtPlusPlus/api/objects/data/Pair.java new file mode 100644 index 0000000000..6ab781cf1e --- /dev/null +++ b/src/Java/gtPlusPlus/api/objects/data/Pair.java @@ -0,0 +1,27 @@ +package gtPlusPlus.api.objects.data; + +import java.io.Serializable; + +public class Pair<K,V> implements Serializable { + + /** + * SVUID + */ + private static final long serialVersionUID = 1250550491092812443L; + private final K key; + private final V value; + + public Pair(final K key, final V value){ + this.key = key; + this.value = value; + } + + final public K getKey(){ + return this.key; + } + + final public V getValue(){ + return this.value; + } + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/api/objects/data/Quad.java b/src/Java/gtPlusPlus/api/objects/data/Quad.java new file mode 100644 index 0000000000..01c62e95e6 --- /dev/null +++ b/src/Java/gtPlusPlus/api/objects/data/Quad.java @@ -0,0 +1,33 @@ +package gtPlusPlus.api.objects.data; + +public class Quad<K,V,C,R> { + + private final K key; + private final V value; + private final C value2; + private final R value3; + + public Quad(final K key, final V value, final C value2, final R value3){ + this.key = key; + this.value = value; + this.value2 = value2; + this.value3 = value3; + } + + final public K getKey(){ + return this.key; + } + + final public V getValue_1(){ + return this.value; + } + + final public C getValue_2(){ + return this.value2; + } + + final public R getValue_3(){ + return this.value3; + } + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/api/objects/data/Triplet.java b/src/Java/gtPlusPlus/api/objects/data/Triplet.java new file mode 100644 index 0000000000..affb03d868 --- /dev/null +++ b/src/Java/gtPlusPlus/api/objects/data/Triplet.java @@ -0,0 +1,27 @@ +package gtPlusPlus.api.objects.data; + +public class Triplet<K,V,C> { + + private final K key; + private final V value; + private final C count; + + public Triplet(final K key, final V value, final C value2){ + this.key = key; + this.value = value; + this.count = value2; + } + + final public K getValue_1(){ + return this.key; + } + + final public V getValue_2(){ + return this.value; + } + + final public C getValue_3(){ + return this.count; + } + +}
\ No newline at end of file |