20 package org.matsim.core.utils.collections;
25 import java.util.Arrays;
26 import java.util.Collection;
27 import java.util.Iterator;
28 import java.util.LinkedHashSet;
30 import java.util.NoSuchElementException;
45 private T[]
data = (T[]) EMPTY;
49 return this.data.length;
54 return this.data.length == 0;
60 if (o.getId().equals(key)) {
70 if (o.equals(value)) {
78 public T
get(
final Object key) {
80 if (o.getId().equals(key)) {
87 public T
put(
final T value) {
88 return put(value.getId(), value);
93 for (
int i = 0; i < this.data.length; i++) {
95 if (old.getId().equals(key)) {
100 this.data = Arrays.copyOf(this.data, this.data.length + 1);
101 this.data[this.data.length - 1] = value;
106 public T
remove(
final Object key) {
107 for (
int i = 0; i < this.data.length; i++) {
108 T old = this.data[i];
109 if (old.getId().equals(key)) {
113 System.arraycopy(this.data, 0, tmp, 0, i);
115 if (i + 1 < this.data.length) {
116 System.arraycopy(this.data, i + 1, tmp, i, this.data.length - 1 - i);
118 this.data = (T[]) tmp;
128 for (T t : m.values()) {
140 Set<Id<S>> ids =
new LinkedHashSet<Id<S>>();
154 Set<Map.Entry<
Id<S>, T>> entries =
new LinkedHashSet<Map.Entry<
Id<S>, T>>();
171 return this.t.getId();
181 throw new UnsupportedOperationException();
203 return this.data.length;
208 return this.data.length == 0;
213 for (A
t : this.data) {
231 return this.data.clone();
235 public <TT> TT[] toArray(
final TT[] a) {
237 if (a.length !=
this.data.length) {
238 dest = Arrays.copyOf(a, this.data.length);
240 System.arraycopy(this.data, 0, dest, 0, this.data.length);
246 throw new UnsupportedOperationException();
250 public boolean remove(Object o) {
251 throw new UnsupportedOperationException();
257 boolean isPartOf = this.contains(o);
266 public boolean addAll(Collection<? extends A> c) {
267 throw new UnsupportedOperationException();
272 throw new UnsupportedOperationException();
277 throw new UnsupportedOperationException();
282 throw new UnsupportedOperationException();
297 return this.pos < data.length;
302 if (this.pos < data.length) {
303 B
t = data[this.pos];
307 throw new NoSuchElementException();
311 public void remove() {
312 throw new UnsupportedOperationException();
static final Identifiable [] EMPTY
ArrayCollection(final A[] data)
boolean retainAll(Collection<?> c)
boolean containsKey(final Object key)
ArrayIterator(final B[] data)
boolean containsValue(final Object value)
T put(final Id< S > key, final T value)
T setValue(final T value)
boolean contains(Object o)
boolean containsAll(Collection<?> c)
void putAll(final Map<? extends Id< S >, ? extends T > m)
boolean addAll(Collection<? extends A > c)
Set< java.util.Map.Entry< Id< S >, T > > entrySet()
boolean removeAll(Collection<?> c)