Class ArrayBunch

java.lang.Object
org.apache.jena.mem.store.legacy.ArrayBunch
All Implemented Interfaces:
Iterable<Triple>, org.apache.jena.atlas.lib.Copyable<TripleBunch>, JenaMapSetCommon<Triple>, JenaSet<Triple>, Sized, TripleBunch

public class ArrayBunch extends Object implements TripleBunch
An ArrayBunch implements TripleBunch with a linear search of a short-ish array of Triples. The array can grow, but it only grows by 4 elements each time (because, if it gets big enough for this linear growth to be bad, it should always have been replaced by a more efficient set-of-triples implementation).
  • Constructor Details

    • ArrayBunch

      public ArrayBunch()
  • Method Details

    • containsKey

      public boolean containsKey(Triple t)
      Description copied from interface: JenaMapSetCommon
      Check whether the collection contains a given key.
      Specified by:
      containsKey in interface JenaMapSetCommon<Triple>
      Parameters:
      t - the key to look for
      Returns:
      true if the collection contains the key
    • anyMatch

      public boolean anyMatch(Predicate<Triple> predicate)
      Description copied from interface: JenaMapSetCommon
      Check whether the collection contains any element matching the predicate.
      Specified by:
      anyMatch in interface JenaMapSetCommon<Triple>
      Parameters:
      predicate - the predicate to match
      Returns:
      true if the collection contains any element matching the predicate
    • clear

      public void clear()
      Description copied from interface: JenaMapSetCommon
      Clear the collection.
      Specified by:
      clear in interface JenaMapSetCommon<Triple>
    • size

      public int size()
      Specified by:
      size in interface Sized
      Returns:
      the number of elements in the collection
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface JenaMapSetCommon<Triple>
      Returns:
      true if the collection is empty
    • tryAdd

      public boolean tryAdd(Triple t)
      Description copied from interface: JenaSet
      Add the key to the set if it is not already present.
      Specified by:
      tryAdd in interface JenaSet<Triple>
      Parameters:
      t - the key to add. (null is not allowed)
      Returns:
      true if the key was added, false if it was already present
    • addUnchecked

      public void addUnchecked(Triple t)
      Description copied from interface: JenaSet
      Add the key to the set without checking whether it is already present.

      Attention: this method must only be used if the caller has ensured that the key is not already in the set; otherwise the set's invariants will break (duplicates may be inserted).

      Specified by:
      addUnchecked in interface JenaSet<Triple>
      Parameters:
      t - the key to add. (null is not allowed)
    • tryRemove

      public boolean tryRemove(Triple t)
      Description copied from interface: JenaMapSetCommon
      Tries to remove a key from the collection.
      Specified by:
      tryRemove in interface JenaMapSetCommon<Triple>
      Parameters:
      t - the key to remove
      Returns:
      true if the key was removed. If the key was not present, false is returned.
    • removeUnchecked

      public void removeUnchecked(Triple t)
      Description copied from interface: JenaMapSetCommon
      Removes a key from the collection.

      Attention: implementations may assume the key is present and may produce undefined behavior (including silently corrupting internal state) if it is not. Use JenaMapSetCommon.tryRemove(Object) when in doubt.

      Specified by:
      removeUnchecked in interface JenaMapSetCommon<Triple>
      Parameters:
      t - the key to remove
    • keyIterator

      public ExtendedIterator<Triple> keyIterator()
      Description copied from interface: JenaMapSetCommon
      Get an iterator over the keys in the collection.
      Specified by:
      keyIterator in interface JenaMapSetCommon<Triple>
      Returns:
      an iterator over the keys in the collection
    • keySpliterator

      public Spliterator<Triple> keySpliterator()
      Description copied from interface: JenaMapSetCommon
      Get a spliterator over the keys in the collection.
      Specified by:
      keySpliterator in interface JenaMapSetCommon<Triple>
      Returns:
      a spliterator over the keys in the collection
    • isArray

      public boolean isArray()
      Description copied from interface: TripleBunch
      Answer true iff this bunch is implemented as an array. This field is used to optimize some operations by avoiding the need for instanceOf tests.
      Specified by:
      isArray in interface TripleBunch
      Returns:
      true iff this bunch is implemented as an arrays
    • copy

      public ArrayBunch copy()
      Specified by:
      copy in interface org.apache.jena.atlas.lib.Copyable<TripleBunch>
    • forEach

      public void forEach(Consumer<? super Triple> action)
      Specified by:
      forEach in interface Iterable<Triple>
      Specified by:
      forEach in interface JenaSet<Triple>