org.crosswire.common.util

## Class ListSet<E>

- java.lang.Object
- - java.util.AbstractCollection<E>
  - - org.crosswire.common.util.ListSet<E>

- Type Parameters:
    `E` - The type of the element in this ListSet.
  All Implemented Interfaces:
    Iterable<E>, Collection<E>, Set<E>

      public class ListSet<E>
      extends AbstractCollection<E>
      implements Set<E>

  Defines a List that maintains the uniqueness of elements
  Author:
    DM Smith
  See Also:
    `The GNU Lesser General Public License for details.`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected List<E>` | `list`
    `protected Set<E>` | `set`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ListSet()` Constructs a new, empty list set.
    `ListSet(Comparator<? super E> comparator)` Constructs a new, empty list set, sorted according to the specified comparator.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `add(E e)`
    `void` | `clear()`
    `boolean` | `contains(Object o)`
    `boolean` | `containsAll(Collection<?> c)`
    `E` | `get(int index)`
    `E` | `get(int index, E defaultValue)`
    `boolean` | `isEmpty()`
    `Iterator<E>` | `iterator()`
    `E` | `remove(int index)`
    `boolean` | `remove(Object o)`
    `boolean` | `retainAll(Collection<?> c)`
    `int` | `size()`
    `Object[]` | `toArray()`
    `<T> T[]` | `toArray(T[] a)`

    - ### Methods inherited from class java.util.AbstractCollection

      `addAll, removeAll, toString`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface java.util.Set

      `addAll, equals, hashCode, removeAll`

- - ### Field Detail

    - #### list

          protected List<E> list

    - #### set

          protected Set<E> set

  - ### Constructor Detail

    - #### ListSet

          public ListSet()

      Constructs a new, empty list set.

    - #### ListSet

          public ListSet(Comparator<? super E> comparator)

      Constructs a new, empty list set, sorted according to the specified comparator. All elements inserted into the set must be mutually comparable by the specified comparator: `comparator.compare(e1, e2)` must not throw a `ClassCastException` for any elements `e1` and `e2` in the set. If the user attempts to add an element to the set that violates this constraint, the `add` call will throw a `ClassCastException`.
      Parameters:
        `comparator` - the comparator that will be used to order this set. If `null`, the natural ordering of the elements will be used.

  - ### Method Detail

    - #### contains

          public boolean contains(Object o)

      Specified by:
        `contains` in interface `Collection<E>`
      Specified by:
        `contains` in interface `Set<E>`
      Overrides:
        `contains` in class `AbstractCollection<E>`

    - #### add

          public boolean add(E e)

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

    - #### remove

          public boolean remove(Object o)

      Specified by:
        `remove` in interface `Collection<E>`
      Specified by:
        `remove` in interface `Set<E>`
      Overrides:
        `remove` in class `AbstractCollection<E>`

    - #### remove

          public E remove(int index)

    - #### containsAll

          public boolean containsAll(Collection<?> c)

      Specified by:
        `containsAll` in interface `Collection<E>`
      Specified by:
        `containsAll` in interface `Set<E>`
      Overrides:
        `containsAll` in class `AbstractCollection<E>`

    - #### retainAll

          public boolean retainAll(Collection<?> c)

      Specified by:
        `retainAll` in interface `Collection<E>`
      Specified by:
        `retainAll` in interface `Set<E>`
      Overrides:
        `retainAll` in class `AbstractCollection<E>`

    - #### size

          public int size()

      Specified by:
        `size` in interface `Collection<E>`
      Specified by:
        `size` in interface `Set<E>`
      Specified by:
        `size` in class `AbstractCollection<E>`

    - #### isEmpty

          public boolean isEmpty()

      Specified by:
        `isEmpty` in interface `Collection<E>`
      Specified by:
        `isEmpty` in interface `Set<E>`
      Overrides:
        `isEmpty` in class `AbstractCollection<E>`

    - #### clear

          public void clear()

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

    - #### get

          public E get(int index)

    - #### get

          public E get(int index,
              E defaultValue)

    - #### iterator

          public Iterator<E> iterator()

      Specified by:
        `iterator` in interface `Iterable<E>`
      Specified by:
        `iterator` in interface `Collection<E>`
      Specified by:
        `iterator` in interface `Set<E>`
      Specified by:
        `iterator` in class `AbstractCollection<E>`

    - #### toArray

          public Object[] toArray()

      Specified by:
        `toArray` in interface `Collection<E>`
      Specified by:
        `toArray` in interface `Set<E>`
      Overrides:
        `toArray` in class `AbstractCollection<E>`

    - #### toArray

          public <T> T[] toArray(T[] a)

      Specified by:
        `toArray` in interface `Collection<E>`
      Specified by:
        `toArray` in interface `Set<E>`
      Overrides:
        `toArray` in class `AbstractCollection<E>`