net.ranides.assira.collection.set
Class IdentitySet<T>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractSet<T>
net.ranides.assira.collection.set.IdentitySet<T>
- Type Parameters:
T -
- All Implemented Interfaces:
- Iterable<T>, Collection<T>, Set<T>
public final class IdentitySet<T>
- extends AbstractSet<T>
Zbiór, który nie używa metody equals do porównywania elementów, lecz
sprawdza identyczność referencji. Wersja znacznie wydajniejsza od naiwnej
implementacji opierającej się na IdentityHashMap wzorowana na kodzie
udostępnianym na
www.koders.com
będącym częścią projektu Maxwell Assembler.
Porównać z cięższą wersją używającą linkowanych węzłów z:
castor.org
- Author:
- ranides
|
Constructor Summary |
IdentitySet()
Tworzy nowy zbiór o początkowej capacity = 16. |
IdentitySet(int initialCapacity)
Tworzy nowy zbiór o określonej pojemności oraz loadFactor = 75%. |
IdentitySet(int initialCapacity,
float loadFactor)
Tworzy nowy zbiór o określonej początkowej capacity oraz loadFactor |
IdentitySet
public IdentitySet()
- Tworzy nowy zbiór o początkowej
capacity = 16.
IdentitySet
public IdentitySet(int initialCapacity)
- Tworzy nowy zbiór o określonej pojemności oraz
loadFactor = 75%.
- Parameters:
initialCapacity -
IdentitySet
public IdentitySet(int initialCapacity,
float loadFactor)
- Tworzy nowy zbiór o określonej początkowej
capacity oraz loadFactor
- Parameters:
initialCapacity - loadFactor -
add
public boolean add(T element)
- Specified by:
add in interface Collection<T>- Specified by:
add in interface Set<T>- Overrides:
add in class AbstractCollection<T>
contains
public boolean contains(Object element)
- Specified by:
contains in interface Collection<T>- Specified by:
contains in interface Set<T>- Overrides:
contains in class AbstractCollection<T>
remove
public boolean remove(Object element)
- Specified by:
remove in interface Collection<T>- Specified by:
remove in interface Set<T>- Overrides:
remove in class AbstractCollection<T>
size
public int size()
- Specified by:
size in interface Collection<T>- Specified by:
size in interface Set<T>- Specified by:
size in class AbstractCollection<T>
iterator
public Iterator<T> iterator()
- Specified by:
iterator in interface Iterable<T>- Specified by:
iterator in interface Collection<T>- Specified by:
iterator in interface Set<T>- Specified by:
iterator in class AbstractCollection<T>
clear
public void clear()
- Specified by:
clear in interface Collection<T>- Specified by:
clear in interface Set<T>- Overrides:
clear in class AbstractCollection<T>
toArray
public Object[] toArray()
- Specified by:
toArray in interface Collection<T>- Specified by:
toArray in interface Set<T>- Overrides:
toArray in class AbstractCollection<T>
toArray
public <T> T[] toArray(T[] target)
- Specified by:
toArray in interface Collection<T>- Specified by:
toArray in interface Set<T>- Overrides:
toArray in class AbstractCollection<T>
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty in interface Collection<T>- Specified by:
isEmpty in interface Set<T>- Overrides:
isEmpty in class AbstractCollection<T>
Copyright © 2013. All Rights Reserved.