Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## edu.emory.mathcs.util.collections.longs
Interface LongSet

All Superinterfaces:
  LongCollection

All Known Subinterfaces:
  LongInterval, LongSortedSet

All Known Implementing Classes:
  AbstractLongInterval, AbstractLongSet, AbstractLongSortedSet

public interface LongSet
extends LongCollection

Set is a collection with no duplicate elements. Primitive sets have some features not found in object sets. A primitive set is associated with a domain with boundaries defined by `min()` and `max()`. All numbers contained within this set must fit between min and max, inclusive. Attempt to add a number from outside the domain will have no effect.

It is possible to obtain a complement view of a primitive set, using `complementSet()`. The complement view contains all numbers between min and max, inclusive, which are not contained in this set. (In other words, complement view never contains numbers from outside of the domain of this set).

Contrary to standard Java collections, intervals in this primitive collection package are inclusive on both sides. In other words, interval [min, max] contains all numbers c such that min <= c <= max. (Otherwise, MAX_VALUE could not be put in the set).

Version:
  1.0
Author:
  Dawid Kurzyniec

Method Summary
`boolean` | `add(long e)` Adds the specified number to this set if it is not already present and if it falls within the domain.
`boolean` | `addAll(LongCollection c)` Adds all of the elements in the specified collection to this set if they're not already present, and if they fall within this set's domain.
`boolean` | `addInterval(long first, long last)` Adds to this set all the numbers between first and last, inclusive, that are not already present in this set and belong to this set's domain.
`void` | `clear()` Removes all of the elements from this set.
`LongSet` | `complementSet()` Returns a complement view of this set.
`boolean` | `contains(long e)` Returns true if this set contains the specified number; false otherwise.
`boolean` | `containsAll(LongCollection c)` Returns `true` if this set contains all of the elements of the specified collection.
`boolean` | `containsInterval(long first, long last)` Returns true if this set contains all the numbers between first and last, inclusive; false otherwise.
`boolean` | `equals(java.lang.Object o)` Two sets are equal if they consists of the same elements.
`int` | `hashCode()`
`boolean` | `isEmpty()` Returns true if this set is empty; false otherwise.
`LongIterator` | `iterator()` Returns the iterator over numbers contained in this set.
`long` | `max()` The largest number that can be stored in this set.
`long` | `min()` The smallest number that can be stored in this set.
`boolean` | `remove(long e)` Removes the specified number from this set if it is present.
`boolean` | `removeAll(LongCollection c)` Removes from this set all of its elements that are contained in the specified collection.
`boolean` | `removeInterval(long first, long last)` Removes from this set all the numbers between first and last, inclusive.
`boolean` | `retainAll(LongCollection c)` Retains only the elements in this set that are contained in the specified collection.
`boolean` | `retainInterval(long first, long last)` Retains in this set only the numbers between first and last, inclusive.
`int` | `size()` Returns the number of elements in this set.
`long` | `size64()` // PREPROC: Long,Int only Returns the number of elements in this set.
`long[]` | `toArray()` Returns the newly allocated array containing all numbers from this set, in the order returned by its iterator.
`long[]` | `toArray(long[] a)` Returns an array containing all of the numbers in this set.

Method Detail

### min

    public long min()

  The smallest number that can be stored in this set.

  Returns:
    the smallest number that can be stored in this set

### max

    public long max()

  The largest number that can be stored in this set.

  Returns:
    the largest number that can be stored in this set

### size

    public int size()

  Returns the number of elements in this set. If exceeds Integer.MAX_VALUE, then Integer.MAX_VALUE is returned. // PREPROC: Long,Int only

  Specified by:
    `size` in interface `LongCollection`

### size64

    public long size64()

  // PREPROC: Long,Int only Returns the number of elements in this set. // PREPROC: Long,Int only

  Specified by:
    `size64` in interface `LongCollection`

### isEmpty

    public boolean isEmpty()

  Returns true if this set is empty; false otherwise.

  Specified by:
    `isEmpty` in interface `LongCollection`
  Returns:
    true if this set is empty; false otherwise

### contains

    public boolean contains(long e)

  Returns true if this set contains the specified number; false otherwise.

  Specified by:
    `contains` in interface `LongCollection`
  Returns:
    true if this set contains the specified number; false otherwise

### iterator

    public LongIterator iterator()

  Returns the iterator over numbers contained in this set.

  Specified by:
    `iterator` in interface `LongCollection`
  Returns:
    the iterator over numbers contained in this set

### toArray

    public long[] toArray()

  Returns the newly allocated array containing all numbers from this set, in the order returned by its iterator.

  Specified by:
    `toArray` in interface `LongCollection`
  Returns:
    the array containing all numbers from this set

### toArray

    public long[] toArray(long[] a)

  Returns an array containing all of the numbers in this set. If the set fits in the specified array, it is returned therein. Otherwise, a new array is allocated.

  If this set makes any guarantees as to what order its elements are returned by its iterator, this method must return the elements in the same order.

  Like the `toArray()` method, this method acts as bridge between array-based and collection-based APIs. Further, this method may, under certain circumstances, be used to save allocation costs.

  Specified by:
    `toArray` in interface `LongCollection`
  Parameters:
    `a` - the array into which the elements of this set are to be stored, if it is big enough; otherwise, a new array is allocated for this purpose.
  Returns:
    an array containing all the elements in this set
  Throws:
    `java.lang.NullPointerException` - if the specified array is null

### add

    public boolean add(long e)

  Adds the specified number to this set if it is not already present and if it falls within the domain.

  Specified by:
    `add` in interface `LongCollection`
  Parameters:
    `e` - number to be added to this collection
  Returns:
    `true` if successfully added

### remove

    public boolean remove(long e)

  Removes the specified number from this set if it is present.

  Specified by:
    `remove` in interface `LongCollection`
  Parameters:
    `e` - number to be removed from this collection
  Returns:
    `true` if successfully removed

### containsAll

    public boolean containsAll(LongCollection c)

  Returns `true` if this set contains all of the elements of the specified collection. If the specified collection is also a set, this method returns `true` if it is a subset of this set.

  Specified by:
    `containsAll` in interface `LongCollection`
  Parameters:
    `c` - collection to be checked for containment in this set
  Returns:
    `true` if this set contains all of the elements of the specified collection
  Throws:
    `java.lang.NullPointerException` - if the specified collection is null
  See Also:
    `contains(long)`

### addAll

    public boolean addAll(LongCollection c)

  Adds all of the elements in the specified collection to this set if they're not already present, and if they fall within this set's domain. If the specified collection is also a set, the `addAll` operation effectively modifies this set so that its value is the union of the two sets, intersected with this set's domain. The behavior of this operation is undefined if the specified collection is modified while the operation is in progress.

  Specified by:
    `addAll` in interface `LongCollection`
  Parameters:
    `c` - collection containing elements to be added to this set
  Returns:
    `true` if this set changed as a result of the call
  Throws:
    `java.lang.NullPointerException` - if the specified collection is null
  See Also:
    `add(long)`

### retainAll

    public boolean retainAll(LongCollection c)

  Retains only the elements in this set that are contained in the specified collection. In other words, removes from this set all of its elements that are not contained in the specified collection. If the specified collection is also a set, this operation effectively modifies this set so that its value is the intersection of the two sets.

  Specified by:
    `retainAll` in interface `LongCollection`
  Parameters:
    `c` - collection containing elements to be retained in this set
  Returns:
    `true` if this set changed as a result of the call
  See Also:
    `remove(long)`

### removeAll

    public boolean removeAll(LongCollection c)

  Removes from this set all of its elements that are contained in the specified collection. If the specified collection is also a set, this operation effectively modifies this set so that its value is the asymmetric set difference of the two sets.

  Specified by:
    `removeAll` in interface `LongCollection`
  Parameters:
    `c` - collection containing elements to be removed from this set
  Returns:
    `true` if this set changed as a result of the call
  See Also:
    `remove(long)`

### complementSet

    public LongSet complementSet()

  Returns a complement view of this set. Complement view is a set that has the same domain as this set, and consists of all numbers from the domain that are not contained in this set. Changes done to this set are reflected in the complement view after it is created.

  Returns:
    the complement view of this set

### clear

    public void clear()

  Removes all of the elements from this set. The set will be empty after this call returns.

  Specified by:
    `clear` in interface `LongCollection`

### equals

    public boolean equals(java.lang.Object o)

  Two sets are equal if they consists of the same elements.

  Specified by:
    `equals` in interface `LongCollection`

### hashCode

    public int hashCode()

  Specified by:
    `hashCode` in interface `LongCollection`
  Returns:
    int

### containsInterval

    public boolean containsInterval(long first,
                                    long last)

  Returns true if this set contains all the numbers between first and last, inclusive; false otherwise.

  Returns:
    true if this set contains the specified interval; false otherwise

### addInterval

    public boolean addInterval(long first,
                               long last)

  Adds to this set all the numbers between first and last, inclusive, that are not already present in this set and belong to this set's domain.

  Parameters:
    `first` - the beginning of the interval (inclusive)
    `last` - the end of the interval (inclusive)
  Returns:
    `true` if this set changed as a result of the call
  See Also:
    `add(long)`

### retainInterval

    public boolean retainInterval(long first,
                                  long last)

  Retains in this set only the numbers between first and last, inclusive. In other words, removes from this set all the numbers outside the specified interval.

  Parameters:
    `first` - the beginning of the interval (inclusive)
    `last` - the end of the interval (inclusive)
  Returns:
    `true` if this set changed as a result of the call
  See Also:
    `#retainAll()`

### removeInterval

    public boolean removeInterval(long first,
                                  long last)

  Removes from this set all the numbers between first and last, inclusive.

  Parameters:
    `first` - the beginning of the interval (inclusive)
    `last` - the end of the interval (inclusive)
  Returns:
    `true` if this set changed as a result of the call
  See Also:
    `remove(long)`, `#removeAll()`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD