org.javimmutable.collections.common
Class AbstractJImmutableSet<T>

java.lang.Object
  extended by org.javimmutable.collections.common.AbstractJImmutableSet<T>
All Implemented Interfaces:
Iterable<T>, Cursorable<T>, Insertable<T>, JImmutableSet<T>
Direct Known Subclasses:
JImmutableHashSet, JImmutableInsertOrderSet, JImmutableTreeSet

@Immutable
public abstract class AbstractJImmutableSet<T>
extends Object
implements JImmutableSet<T>


Constructor Summary
protected AbstractJImmutableSet(JImmutableMap<T,Boolean> map)
           
 
Method Summary
 boolean contains(T value)
          Determines if the Set contains the specified value.
 boolean containsAll(Collection<? extends T> values)
          Determines if the Set contains all values in the specified collection.
 boolean containsAll(Cursor<? extends T> values)
          Determines if the Set contains all values in the specified collection.
 boolean containsAll(Cursorable<? extends T> values)
          Determines if the Set contains all values in the specified collection.
 boolean containsAll(Iterator<? extends T> values)
          Determines if the Set contains all values in the specified collection.
 boolean containsAny(Collection<? extends T> values)
          Determines if the Set contains any values in the specified collection.
 boolean containsAny(Cursor<? extends T> values)
          Determines if the Set contains any values in the specified collection.
 boolean containsAny(Cursorable<? extends T> values)
          Determines if the Set contains any values in the specified collection.
 boolean containsAny(Iterator<? extends T> values)
          Determines if the Set contains any values in the specified collection.
protected abstract  JImmutableSet<T> create(JImmutableMap<T,Boolean> map)
          Implemented by derived classes to create a new instance of the appropriate class.
 Cursor<T> cursor()
           
 JImmutableSet<T> delete(T value)
          Removes the value from the Set.
 JImmutableSet<T> deleteAll(Collection<? extends T> other)
          Removes all values of other from the Set.
 JImmutableSet<T> deleteAll(Cursor<? extends T> values)
          Removes all values of other from the Set.
 JImmutableSet<T> deleteAll(Cursorable<? extends T> other)
          Removes all values of other from the Set.
 JImmutableSet<T> deleteAll(Iterator<? extends T> values)
          Removes all values of other from the Set.
protected abstract  JImmutableMap<T,Boolean> emptyMap()
          Implemented by derived classes to create a new empty PersistentMap for use by retainAll()
 boolean equals(Object o)
           
 Set<T> getSet()
           
 int hashCode()
           
 JImmutableSet<T> insert(T value)
          Adds the single value to the Set.
 JImmutableSet<T> intersection(Collection<? extends T> other)
          Removes all values from the Set that are not contained in the other collection.
 JImmutableSet<T> intersection(Cursor<? extends T> values)
          Removes all values from the Set that are not contained in the other collection.
 JImmutableSet<T> intersection(Cursorable<? extends T> other)
          Removes all values from the Set that are not contained in the other collection.
 JImmutableSet<T> intersection(Iterator<? extends T> values)
          Removes all values from the Set that are not contained in the other collection.
 JImmutableSet<T> intersection(JImmutableSet<T> other)
          Removes all values from the Set that are not contained in the other collection.
 JImmutableSet<T> intersection(Set<? extends T> other)
          Removes all values from the Set that are not contained in the other collection.
 boolean isEmpty()
           
 Iterator<T> iterator()
           
 int size()
          Determines the number of values in the Set.
 String toString()
           
 JImmutableSet<T> union(Collection<? extends T> other)
          Adds all values from other to the Set.
 JImmutableSet<T> union(Cursor<? extends T> values)
          Adds all values from other to the Set.
 JImmutableSet<T> union(Cursorable<? extends T> other)
          Adds all values from other to the Set.
 JImmutableSet<T> union(Iterator<? extends T> values)
          Adds all values from other to the Set.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.javimmutable.collections.JImmutableSet
deleteAll
 

Constructor Detail

AbstractJImmutableSet

protected AbstractJImmutableSet(JImmutableMap<T,Boolean> map)
Method Detail

insert

@Nonnull
public JImmutableSet<T> insert(@Nonnull
                                       T value)
Description copied from interface: JImmutableSet
Adds the single value to the Set.

Specified by:
insert in interface Insertable<T>
Specified by:
insert in interface JImmutableSet<T>
Returns:
instance of set containing the value

contains

public boolean contains(@Nullable
                        T value)
Description copied from interface: JImmutableSet
Determines if the Set contains the specified value.

Specified by:
contains in interface JImmutableSet<T>
Returns:
true if the Set contains the value

containsAll

public boolean containsAll(@Nonnull
                           Cursorable<? extends T> values)
Description copied from interface: JImmutableSet
Determines if the Set contains all values in the specified collection.

Specified by:
containsAll in interface JImmutableSet<T>
Returns:
true if the Set contains the values

containsAll

public boolean containsAll(@Nonnull
                           Collection<? extends T> values)
Description copied from interface: JImmutableSet
Determines if the Set contains all values in the specified collection.

Specified by:
containsAll in interface JImmutableSet<T>
Returns:
true if the Set contains the values

containsAll

public boolean containsAll(@Nonnull
                           Cursor<? extends T> values)
Description copied from interface: JImmutableSet
Determines if the Set contains all values in the specified collection.

Specified by:
containsAll in interface JImmutableSet<T>
Returns:
true if the Set contains the values

containsAll

public boolean containsAll(@Nonnull
                           Iterator<? extends T> values)
Description copied from interface: JImmutableSet
Determines if the Set contains all values in the specified collection.

Specified by:
containsAll in interface JImmutableSet<T>
Returns:
true if the Set contains the values

containsAny

public boolean containsAny(@Nonnull
                           Cursorable<? extends T> values)
Description copied from interface: JImmutableSet
Determines if the Set contains any values in the specified collection.

Specified by:
containsAny in interface JImmutableSet<T>
Returns:
true if the Set contains a value

containsAny

public boolean containsAny(@Nonnull
                           Collection<? extends T> values)
Description copied from interface: JImmutableSet
Determines if the Set contains any values in the specified collection.

Specified by:
containsAny in interface JImmutableSet<T>
Returns:
true if the Set contains a value

containsAny

public boolean containsAny(@Nonnull
                           Cursor<? extends T> values)
Description copied from interface: JImmutableSet
Determines if the Set contains any values in the specified collection.

Specified by:
containsAny in interface JImmutableSet<T>
Returns:
true if the Set contains a value

containsAny

public boolean containsAny(@Nonnull
                           Iterator<? extends T> values)
Description copied from interface: JImmutableSet
Determines if the Set contains any values in the specified collection.

Specified by:
containsAny in interface JImmutableSet<T>
Returns:
true if the Set contains a value

delete

@Nonnull
public JImmutableSet<T> delete(T value)
Description copied from interface: JImmutableSet
Removes the value from the Set. Has no effect if the value is not in the Set.

Specified by:
delete in interface JImmutableSet<T>
Returns:
instance of set without the value

deleteAll

@Nonnull
public JImmutableSet<T> deleteAll(@Nonnull
                                          Cursorable<? extends T> other)
Description copied from interface: JImmutableSet
Removes all values of other from the Set. Has no effect if none of the values are in the Set

Specified by:
deleteAll in interface JImmutableSet<T>
Returns:
instance of set without the values

deleteAll

@Nonnull
public JImmutableSet<T> deleteAll(@Nonnull
                                          Collection<? extends T> other)
Description copied from interface: JImmutableSet
Removes all values of other from the Set. Has no effect if none of the values are in the Set

Specified by:
deleteAll in interface JImmutableSet<T>
Returns:
instance of set without the values

deleteAll

@Nonnull
public JImmutableSet<T> deleteAll(@Nonnull
                                          Cursor<? extends T> values)
Description copied from interface: JImmutableSet
Removes all values of other from the Set. Has no effect if none of the values are in the Set

Specified by:
deleteAll in interface JImmutableSet<T>
Returns:
instance of set without the values

deleteAll

@Nonnull
public JImmutableSet<T> deleteAll(@Nonnull
                                          Iterator<? extends T> values)
Description copied from interface: JImmutableSet
Removes all values of other from the Set. Has no effect if none of the values are in the Set

Specified by:
deleteAll in interface JImmutableSet<T>
Returns:
instance of set without the values

union

@Nonnull
public JImmutableSet<T> union(@Nonnull
                                      Cursorable<? extends T> other)
Description copied from interface: JImmutableSet
Adds all values from other to the Set.

Specified by:
union in interface JImmutableSet<T>
Parameters:
other - source of values to add
Returns:
instance of set containing the values

union

@Nonnull
public JImmutableSet<T> union(@Nonnull
                                      Collection<? extends T> other)
Description copied from interface: JImmutableSet
Adds all values from other to the Set.

Specified by:
union in interface JImmutableSet<T>
Parameters:
other - source of values to add
Returns:
instance of set containing the values

union

@Nonnull
public JImmutableSet<T> union(@Nonnull
                                      Cursor<? extends T> values)
Description copied from interface: JImmutableSet
Adds all values from other to the Set.

Specified by:
union in interface JImmutableSet<T>
Parameters:
values - source of values to add
Returns:
instance of set containing the values

union

@Nonnull
public JImmutableSet<T> union(@Nonnull
                                      Iterator<? extends T> values)
Description copied from interface: JImmutableSet
Adds all values from other to the Set.

Specified by:
union in interface JImmutableSet<T>
Parameters:
values - source of values to add
Returns:
instance of set containing the values

intersection

@Nonnull
public JImmutableSet<T> intersection(@Nonnull
                                             Cursorable<? extends T> other)
Description copied from interface: JImmutableSet
Removes all values from the Set that are not contained in the other collection.

Specified by:
intersection in interface JImmutableSet<T>
Returns:
instance of set with unmatched values removed

intersection

@Nonnull
public JImmutableSet<T> intersection(@Nonnull
                                             Collection<? extends T> other)
Description copied from interface: JImmutableSet
Removes all values from the Set that are not contained in the other collection.

Specified by:
intersection in interface JImmutableSet<T>
Returns:
instance of set with unmatched values removed

intersection

@Nonnull
public JImmutableSet<T> intersection(@Nonnull
                                             Cursor<? extends T> values)
Description copied from interface: JImmutableSet
Removes all values from the Set that are not contained in the other collection.

Specified by:
intersection in interface JImmutableSet<T>
Returns:
instance of set with unmatched values removed

intersection

@Nonnull
public JImmutableSet<T> intersection(@Nonnull
                                             Iterator<? extends T> values)
Description copied from interface: JImmutableSet
Removes all values from the Set that are not contained in the other collection.

Specified by:
intersection in interface JImmutableSet<T>
Returns:
instance of set with unmatched values removed

intersection

@Nonnull
public JImmutableSet<T> intersection(@Nonnull
                                             JImmutableSet<T> other)
Description copied from interface: JImmutableSet
Removes all values from the Set that are not contained in the other collection.

Specified by:
intersection in interface JImmutableSet<T>
Returns:
instance of set with unmatched values removed

intersection

@Nonnull
public JImmutableSet<T> intersection(@Nonnull
                                             Set<? extends T> other)
Description copied from interface: JImmutableSet
Removes all values from the Set that are not contained in the other collection.

Specified by:
intersection in interface JImmutableSet<T>
Returns:
instance of set with unmatched values removed

size

public int size()
Description copied from interface: JImmutableSet
Determines the number of values in the Set.

Specified by:
size in interface JImmutableSet<T>
Returns:
number of values in the Set

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface JImmutableSet<T>
Returns:
true only if set contains no values

getSet

@Nonnull
public Set<T> getSet()
Specified by:
getSet in interface JImmutableSet<T>
Returns:
an unmodifiable Set implementation backed by this set.

cursor

@Nonnull
public Cursor<T> cursor()
Specified by:
cursor in interface Cursorable<T>

iterator

public Iterator<T> iterator()
Specified by:
iterator in interface Iterable<T>

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object o)
Overrides:
equals in class Object

toString

public String toString()
Overrides:
toString in class Object

create

protected abstract JImmutableSet<T> create(JImmutableMap<T,Boolean> map)
Implemented by derived classes to create a new instance of the appropriate class.

Parameters:
map -
Returns:

emptyMap

protected abstract JImmutableMap<T,Boolean> emptyMap()
Implemented by derived classes to create a new empty PersistentMap for use by retainAll()

Returns:


Copyright © 2014 Burton Computer Corporation. All rights reserved.