org.optaplanner.core.impl.domain.variable.listener.support

## Class SmallScalingOrderedSet<E>

- java.lang.Object
- - org.optaplanner.core.impl.domain.variable.listener.support.SmallScalingOrderedSet<E>

- Type Parameters:
    `E` -
  All Implemented Interfaces:
    Iterable<E>, Collection<E>, Set<E>

      public final class SmallScalingOrderedSet<E>
      extends Object
      implements Set<E>

  An ordered `Set` which is implemented as a `ArrayList` for a small `Set.size()` and a `LinkedHashSet` for a big `Set.size()`.

  This speeds up `add(Object)` performance (in some cases by 20%) if most instances have a small size because no `Object.hashCode()` need to be calculated.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static int` | `LIST_SIZE_THRESHOLD`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SmallScalingOrderedSet()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `add(E e)`
    `boolean` | `addAll(Collection<? extends E> c)`
    `void` | `clear()`
    `boolean` | `contains(Object o)`
    `boolean` | `containsAll(Collection<?> c)`
    `boolean` | `isEmpty()`
    `Iterator<E>` | `iterator()`
    `boolean` | `remove(Object o)`
    `boolean` | `removeAll(Collection<?> c)`
    `boolean` | `retainAll(Collection<?> c)`
    `int` | `size()`
    `Object[]` | `toArray()`
    `<T> T[]` | `toArray(T[] a)`

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

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

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

      `equals, hashCode, spliterator`

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

      `parallelStream, removeIf, stream`

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

      `forEach`

- - ### Field Detail

    - #### LIST_SIZE_THRESHOLD

          protected static final int LIST_SIZE_THRESHOLD

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### SmallScalingOrderedSet

          public SmallScalingOrderedSet()

  - ### Method Detail

    - #### size

          public int size()

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

    - #### isEmpty

          public boolean isEmpty()

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

    - #### contains

          public boolean contains(Object o)

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

    - #### containsAll

          public boolean containsAll(Collection<?> c)

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

    - #### 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>`

    - #### toArray

          public Object[] toArray()

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

    - #### toArray

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

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

    - #### add

          public boolean add(E e)

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

    - #### addAll

          public boolean addAll(Collection<? extends E> c)

      Specified by:
        `addAll` in interface `Collection<E>`
      Specified by:
        `addAll` in interface `Set<E>`

    - #### remove

          public boolean remove(Object o)

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

    - #### retainAll

          public boolean retainAll(Collection<?> c)

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

    - #### removeAll

          public boolean removeAll(Collection<?> c)

      Specified by:
        `removeAll` in interface `Collection<E>`
      Specified by:
        `removeAll` in interface `Set<E>`

    - #### clear

          public void clear()

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

Copyright © 2006–2020 JBoss by Red Hat. All rights reserved.