com.threerings.util
Class AbstractIdentityHashSet<T>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractSet<T>
          extended by com.threerings.util.AbstractIdentityHashSet<T>
All Implemented Interfaces:
Iterable<T>, Collection<T>, Set<T>
Direct Known Subclasses:
SceneInfluenceSet, ViewerEffectSet

public abstract class AbstractIdentityHashSet<T>
extends AbstractSet<T>

Wraps up an IdentityHashMap to look like a set for the purpose of subclassing. IdentityHashMap has the desirable property of not generating extra objects when elements are added/removed, because it stores the elements directly in its bucket array (resolving collisions using linear probing). Note that if you don't need to subclass the set, then you can just pass an IdentityHashMap to Sets.newSetFromMap(java.util.Map).


Constructor Summary
AbstractIdentityHashSet()
          Creates a new set with the default expected maximum size.
AbstractIdentityHashSet(int expectedMaxSize)
          Creates a new set with the specified expected maximum size.
 
Method Summary
 boolean add(T element)
           
 void clear()
           
 boolean contains(Object object)
           
 Iterator<T> iterator()
           
 boolean remove(Object object)
           
 int size()
           
 
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
 
Methods inherited from class java.util.AbstractCollection
addAll, containsAll, isEmpty, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Set
addAll, containsAll, isEmpty, retainAll, toArray, toArray
 

Constructor Detail

AbstractIdentityHashSet

public AbstractIdentityHashSet()
Creates a new set with the default expected maximum size.


AbstractIdentityHashSet

public AbstractIdentityHashSet(int expectedMaxSize)
Creates a new set with the specified expected maximum size.

Method Detail

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>

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>

remove

public boolean remove(Object object)
Specified by:
remove in interface Collection<T>
Specified by:
remove in interface Set<T>
Overrides:
remove in class AbstractCollection<T>

contains

public boolean contains(Object object)
Specified by:
contains in interface Collection<T>
Specified by:
contains in interface Set<T>
Overrides:
contains 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>

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>


Copyright © 2011. All Rights Reserved.