com.boundary.high_scale_lib
Class NonBlockingHashSetLong

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractSet<Long>
          extended by com.boundary.high_scale_lib.NonBlockingHashSetLong
All Implemented Interfaces:
Serializable, Iterable<Long>, Collection<Long>, Set<Long>

public class NonBlockingHashSetLong
extends AbstractSet<Long>
implements Serializable

A simple wrapper around NonBlockingHashMapLong making it implement the Set interface. All operations are Non-Blocking and multi-thread safe.

See Also:
Serialized Form

Constructor Summary
NonBlockingHashSetLong()
          Make a new empty NonBlockingHashSetLong.
 
Method Summary
 boolean add(long o)
          Add o to the set.
 boolean add(Long o)
          To support AbstractCollection.addAll
 boolean addAll(Collection<? extends Long> c)
           
 void clear()
          Empty the set.
 boolean contains(long o)
           
 boolean contains(Object o)
           
 boolean containsAll(Collection<?> c)
           
 int hashCode()
           
 Iterator<Long> iterator()
           
 LongIterator longIterator()
           
 void readOnly()
          Atomically make the set immutable.
 boolean remove(long o)
          Remove o from the set.
 boolean remove(Object o)
           
 boolean removeAll(Collection<?> c)
           
 boolean retainAll(Collection<?> c)
           
 int size()
          Current count of elements in the set.
 String toString()
           
 
Methods inherited from class java.util.AbstractSet
equals
 
Methods inherited from class java.util.AbstractCollection
isEmpty, toArray, toArray
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Set
isEmpty, toArray, toArray
 

Constructor Detail

NonBlockingHashSetLong

public NonBlockingHashSetLong()
Make a new empty NonBlockingHashSetLong.

Method Detail

addAll

public boolean addAll(Collection<? extends Long> c)
Specified by:
addAll in interface Collection<Long>
Specified by:
addAll in interface Set<Long>
Overrides:
addAll in class AbstractCollection<Long>

removeAll

public boolean removeAll(Collection<?> c)
Specified by:
removeAll in interface Collection<Long>
Specified by:
removeAll in interface Set<Long>
Overrides:
removeAll in class AbstractSet<Long>

containsAll

public boolean containsAll(Collection<?> c)
Specified by:
containsAll in interface Collection<Long>
Specified by:
containsAll in interface Set<Long>
Overrides:
containsAll in class AbstractCollection<Long>

retainAll

public boolean retainAll(Collection<?> c)
Specified by:
retainAll in interface Collection<Long>
Specified by:
retainAll in interface Set<Long>
Overrides:
retainAll in class AbstractCollection<Long>

hashCode

public int hashCode()
Specified by:
hashCode in interface Collection<Long>
Specified by:
hashCode in interface Set<Long>
Overrides:
hashCode in class AbstractSet<Long>

add

public boolean add(long o)
Add o to the set.

Returns:
true if o was added to the set, false if o was already in the set.

add

public boolean add(Long o)
To support AbstractCollection.addAll

Specified by:
add in interface Collection<Long>
Specified by:
add in interface Set<Long>
Overrides:
add in class AbstractCollection<Long>

contains

public boolean contains(long o)
Returns:
true if o is in the set.

contains

public boolean contains(Object o)
Specified by:
contains in interface Collection<Long>
Specified by:
contains in interface Set<Long>
Overrides:
contains in class AbstractCollection<Long>

remove

public boolean remove(long o)
Remove o from the set.

Returns:
true if o was removed to the set, false if o was not in the set.

remove

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

size

public int size()
Current count of elements in the set. Due to concurrent racing updates, the size is only ever approximate. Updates due to the calling thread are immediately visible to calling thread.

Specified by:
size in interface Collection<Long>
Specified by:
size in interface Set<Long>
Specified by:
size in class AbstractCollection<Long>
Returns:
count of elements.

clear

public void clear()
Empty the set.

Specified by:
clear in interface Collection<Long>
Specified by:
clear in interface Set<Long>
Overrides:
clear in class AbstractCollection<Long>

toString

public String toString()
Overrides:
toString in class AbstractCollection<Long>

iterator

public Iterator<Long> iterator()
Specified by:
iterator in interface Iterable<Long>
Specified by:
iterator in interface Collection<Long>
Specified by:
iterator in interface Set<Long>
Specified by:
iterator in class AbstractCollection<Long>

longIterator

public LongIterator longIterator()

readOnly

public void readOnly()
Atomically make the set immutable. Future calls to mutate will throw an IllegalStateException. Existing mutator calls in other threads racing with this thread and will either throw IllegalStateException or their update will be visible to this thread. This implies that a simple flag cannot make the Set immutable, because a late-arriving update in another thread might see immutable flag not set yet, then mutate the Set after the readOnly() call returns. This call can be called concurrently (and indeed until the operation completes, all calls on the Set from any thread either complete normally or end up calling readOnly() internally).

This call is useful in debugging multi-threaded programs where the Set is constructed in parallel, but construction completes after some time; and after construction the Set is only read. Making the Set read-only will cause updates arriving after construction is supposedly complete to throw an IllegalStateException.



Copyright © 2014. All rights reserved.