public XmlSet(PersistenceStrategy persistenceStrategy) { this.map = new XmlMap(persistenceStrategy); }
private Long findEmptyKey() { long i = System.currentTimeMillis(); while (map.containsKey(new Long(i))) { i++; } return new Long(i); }
public boolean add(Object o) { if (map.containsValue(o)) { return false; } else { // not-synchronized! map.put(findEmptyKey(), o); return true; } }
public void add(int index, Object element) { int size = size(); if (index >= (size + 1) || index < 0) { throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + size); } int to = index != size ? index - 1 : index; for (int i = size; i > to; i--) { map.put(new Integer(i + 1), map.get(new Integer(i))); } map.put(new Integer(index), element); }
public int size() { return map.size(); }
public Iterator iterator() { return map.values().iterator(); }
public boolean isEmpty() { return XmlMap.this.isEmpty(); }
public Object get(int index) { rangeCheck(index); return map.get(new Integer(index)); }
public Object set(int index, Object element) { rangeCheck(index); Object value = get(index); map.put(new Integer(index), element); return value; }
public void add(int index, Object element) { int size = size(); if (index >= (size + 1) || index < 0) { throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + size); } int to = index != size ? index - 1 : index; for (int i = size; i > to; i--) { map.put(new Integer(i + 1), map.get(new Integer(i))); } map.put(new Integer(index), element); }
public int size() { return XmlMap.this.size(); }
@Override public Iterator<V> iterator() { return map.values().iterator(); }
public boolean isEmpty() { return XmlMap.this.isEmpty(); }
@Override public V get(final int index) { rangeCheck(index); return map.get(Integer.valueOf(index)); }
@Override public V set(final int index, final V element) { rangeCheck(index); final V value = get(index); map.put(Integer.valueOf(index), element); return value; }
@Override public boolean add(final V o) { if (map.containsValue(o)) { return false; } else { // not-synchronized! map.put(findEmptyKey(), o); return true; } }
public void add(int index, Object element) { int size = size(); if (index >= (size + 1) || index < 0) { throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + size); } int to = index != size ? index - 1 : index; for (int i = size; i > to; i--) { map.put(new Integer(i + 1), map.get(new Integer(i))); } map.put(new Integer(index), element); }