Package org.apache.ignite

## Interface IgniteSet<T>

- All Superinterfaces:
    `AutoCloseable`, `Closeable`, `Collection<T>`, `Iterable<T>`, `Set<T>`

      public interface IgniteSet<T>
      extends Set<T>, Closeable

  Set implementation based on on In-Memory Data Grid.

  # Overview

  Cache set implements `Set` interface and provides all methods from collections. Note that all `Collection` methods in the set may throw `IgniteException` in case of failure or if set was removed.

  # Collocated vs Non-collocated

  Set items can be placed on one node or distributed throughout grid nodes (governed by `collocated` parameter). `Non-collocated` mode is provided only for partitioned caches. If `collocated` parameter is `true`, then all set items will be collocated on one node, otherwise items will be distributed through all grid nodes.
  See Also:
    `Ignite.set(String, org.apache.ignite.configuration.CollectionConfiguration)`

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `boolean` | `add​(T t)`
    `boolean` | `addAll​(Collection<? extends T> c)`
    `<R> R` | `affinityCall​(IgniteCallable<R> job)` | Executes given job on collocated set on the node where the set is located (a.k.a. affinity co-location).
    `void` | `affinityRun​(IgniteRunnable job)` | Executes given job on collocated set on the node where the set is located (a.k.a. affinity co-location).
    `void` | `clear()`
    `void` | `close()` | Removes this set.
    `boolean` | `collocated()` | Returns `true` if this set can be kept on the one node only.
    `boolean` | `contains​(Object o)`
    `boolean` | `containsAll​(Collection<?> c)`
    `boolean` | `isEmpty()`
    `Iterator<T>` | `iterator()`
    `String` | `name()` | Gets set name.
    `boolean` | `remove​(Object o)`
    `boolean` | `removeAll​(Collection<?> c)`
    `boolean` | `removed()` | Gets status of set.
    `boolean` | `retainAll​(Collection<?> c)`
    `int` | `size()`
    `Object[]` | `toArray()`
    `<T1> T1[]` | `toArray​(T1[] a)`
    `<T1> IgniteSet<T1>` | `withKeepBinary()` | Returns Ignite set that operates on binary objects without deserialization.

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

      `parallelStream, removeIf, stream, toArray`

    - ### Methods inherited from interface java.lang.Iterable

      `forEach`

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

      `equals, hashCode, spliterator`

- - ### Method Detail

    - #### add

          boolean add​(T t)
               throws IgniteException

      Specified by:
        `add` in interface `Collection<T>`
      Specified by:
        `add` in interface `Set<T>`
      Throws:
        `IgniteException`

    - #### addAll

          boolean addAll​(Collection<? extends T> c)
                  throws IgniteException

      Specified by:
        `addAll` in interface `Collection<T>`
      Specified by:
        `addAll` in interface `Set<T>`
      Throws:
        `IgniteException`

    - #### clear

          void clear()
              throws IgniteException

      Specified by:
        `clear` in interface `Collection<T>`
      Specified by:
        `clear` in interface `Set<T>`
      Throws:
        `IgniteException`

    - #### contains

          boolean contains​(Object o)
                    throws IgniteException

      Specified by:
        `contains` in interface `Collection<T>`
      Specified by:
        `contains` in interface `Set<T>`
      Throws:
        `IgniteException`

    - #### containsAll

          boolean containsAll​(Collection<?> c)
                       throws IgniteException

      Specified by:
        `containsAll` in interface `Collection<T>`
      Specified by:
        `containsAll` in interface `Set<T>`
      Throws:
        `IgniteException`

    - #### isEmpty

          boolean isEmpty()
                   throws IgniteException

      Specified by:
        `isEmpty` in interface `Collection<T>`
      Specified by:
        `isEmpty` in interface `Set<T>`
      Throws:
        `IgniteException`

    - #### iterator

          Iterator<T> iterator()
                        throws IgniteException

      Specified by:
        `iterator` in interface `Collection<T>`
      Specified by:
        `iterator` in interface `Iterable<T>`
      Specified by:
        `iterator` in interface `Set<T>`
      Throws:
        `IgniteException`

    - #### remove

          boolean remove​(Object o)
                  throws IgniteException

      Specified by:
        `remove` in interface `Collection<T>`
      Specified by:
        `remove` in interface `Set<T>`
      Throws:
        `IgniteException`

    - #### removeAll

          boolean removeAll​(Collection<?> c)
                     throws IgniteException

      Specified by:
        `removeAll` in interface `Collection<T>`
      Specified by:
        `removeAll` in interface `Set<T>`
      Throws:
        `IgniteException`

    - #### retainAll

          boolean retainAll​(Collection<?> c)
                     throws IgniteException

      Specified by:
        `retainAll` in interface `Collection<T>`
      Specified by:
        `retainAll` in interface `Set<T>`
      Throws:
        `IgniteException`

    - #### size

          int size()
            throws IgniteException

      Specified by:
        `size` in interface `Collection<T>`
      Specified by:
        `size` in interface `Set<T>`
      Throws:
        `IgniteException`

    - #### toArray

          Object[] toArray()
                    throws IgniteException

      Specified by:
        `toArray` in interface `Collection<T>`
      Specified by:
        `toArray` in interface `Set<T>`
      Throws:
        `IgniteException`

    - #### toArray

          <T1> T1[] toArray​(T1[] a)
                     throws IgniteException

      Specified by:
        `toArray` in interface `Collection<T>`
      Specified by:
        `toArray` in interface `Set<T>`
      Throws:
        `IgniteException`

    - #### close

          void close()
              throws IgniteException

      Removes this set. In order to check the state it is possible to use `removed()`.
      Specified by:
        `close` in interface `AutoCloseable`
      Specified by:
        `close` in interface `Closeable`
      Throws:
        `IgniteException` - If operation failed.

    - #### name

          String name()

      Gets set name.
      Returns:
        Set name.

    - #### collocated

          boolean collocated()

      Returns `true` if this set can be kept on the one node only. Returns `false` if this set can be kept on the many nodes.
      Returns:
        `True` if this set is in `collocated` mode `false` otherwise.

    - #### removed

          boolean removed()

      Gets status of set. In order to change the status it is possible to use `close()` method.
      Returns:
        `True` if set was removed from cache `false` otherwise.

    - #### affinityRun

          void affinityRun​(IgniteRunnable job)
                    throws IgniteException

      Executes given job on collocated set on the node where the set is located (a.k.a. affinity co-location).

      This is not supported for non-collocated sets.

      Parameters:
        `job` - Job which will be co-located with the set.
      Throws:
        `IgniteException` - If job failed.

    - #### affinityCall

          <R> R affinityCall​(IgniteCallable<R> job)
                      throws IgniteException

      Executes given job on collocated set on the node where the set is located (a.k.a. affinity co-location).

      This is not supported for non-collocated sets.

      Type Parameters:
        `R` - Type of the job result.
      Parameters:
        `job` - Job which will be co-located with the set.
      Returns:
        Job result.
      Throws:
        `IgniteException` - If job failed.

    - #### withKeepBinary

          <T1> IgniteSet<T1> withKeepBinary()

      Returns Ignite set that operates on binary objects without deserialization.
      Type Parameters:
        `T1` - Type of binary objects.
      Returns:
        New set instance for binary objects.