org.gudy.azureus2.core3.util
Class LightHashSet

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractSet
          extended by org.gudy.azureus2.core3.util.LightHashSet
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Iterable, java.util.Collection, java.util.Set

public class LightHashSet
extends java.util.AbstractSet
implements java.lang.Cloneable

A lighter (on memory) hash set
Advantages over HashSet:

Disadvantages:

Author:
Aaron Grunthal

Constructor Summary
LightHashSet()
           
LightHashSet(java.util.Collection c)
           
LightHashSet(int initialCapacity)
           
LightHashSet(int initialCapacity, float loadFactor)
           
 
Method Summary
 boolean add(java.lang.Object key)
           
 boolean addAll(java.util.Collection c)
           
 int capacity()
           
 void clear()
           
 java.lang.Object clone()
           
 void compactify(float compactingLoadFactor)
          will shrink the internal storage size to the least possible amount, should be used after removing many entries for example
 boolean contains(java.lang.Object key)
           
 java.lang.Object get(java.lang.Object key)
          Fetches an element which does equal() the provided object but is not necessarily the same object
 java.util.Iterator iterator()
           
static void main(java.lang.String[] args)
           
 boolean remove(java.lang.Object key)
           
 int size()
           
 
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
 
Methods inherited from class java.util.AbstractCollection
containsAll, isEmpty, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Set
containsAll, isEmpty, retainAll, toArray, toArray
 

Constructor Detail

LightHashSet

public LightHashSet()

LightHashSet

public LightHashSet(int initialCapacity)

LightHashSet

public LightHashSet(java.util.Collection c)

LightHashSet

public LightHashSet(int initialCapacity,
                    float loadFactor)
Method Detail

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

iterator

public java.util.Iterator iterator()
Specified by:
iterator in interface java.lang.Iterable
Specified by:
iterator in interface java.util.Collection
Specified by:
iterator in interface java.util.Set
Specified by:
iterator in class java.util.AbstractCollection

add

public boolean add(java.lang.Object key)
Specified by:
add in interface java.util.Collection
Specified by:
add in interface java.util.Set
Overrides:
add in class java.util.AbstractCollection

size

public int size()
Specified by:
size in interface java.util.Collection
Specified by:
size in interface java.util.Set
Specified by:
size in class java.util.AbstractCollection

addAll

public boolean addAll(java.util.Collection c)
Specified by:
addAll in interface java.util.Collection
Specified by:
addAll in interface java.util.Set
Overrides:
addAll in class java.util.AbstractCollection

capacity

public int capacity()

get

public java.lang.Object get(java.lang.Object key)
Fetches an element which does equal() the provided object but is not necessarily the same object

Parameters:
Object - to retrieve
Returns:
an object fulfilling the equals contract or null if no such object was found in this set

remove

public boolean remove(java.lang.Object key)
Specified by:
remove in interface java.util.Collection
Specified by:
remove in interface java.util.Set
Overrides:
remove in class java.util.AbstractCollection

clear

public void clear()
Specified by:
clear in interface java.util.Collection
Specified by:
clear in interface java.util.Set
Overrides:
clear in class java.util.AbstractCollection

contains

public boolean contains(java.lang.Object key)
Specified by:
contains in interface java.util.Collection
Specified by:
contains in interface java.util.Set
Overrides:
contains in class java.util.AbstractCollection

compactify

public void compactify(float compactingLoadFactor)
will shrink the internal storage size to the least possible amount, should be used after removing many entries for example

Parameters:
compactingLoadFactor - load factor for the compacting operation. Use 0f to compact with the load factor specified during instantiation. Use negative values of the desired load factors to compact only when it would reduce the storage size.

main

public static void main(java.lang.String[] args)