Class AHashSet<T extends ACell>

All Implemented Interfaces:
IAssociative<T,CVMBool>, IValidated, IWriteable, Iterable<T>, Collection<T>, Set<T>
Direct Known Subclasses:
SetLeaf, SetTree

public abstract class AHashSet<T extends ACell> extends ASet<T>
  • Field Details

  • Constructor Details

    • AHashSet

      protected AHashSet(long count)
  • Method Details

    • mergeWith

      protected abstract AHashSet<T> mergeWith(AHashSet<T> b, int setOp)
    • mergeWith

      protected abstract AHashSet<T> mergeWith(AHashSet<T> b, int setOp, int shift)
    • includeAll

      public <R extends ACell> ASet<R> includeAll(ASet<R> elements)
      Description copied from class: ASet
      Updates the set to include all the given elements. Can be used to implement union of sets
      Specified by:
      includeAll in class ASet<T extends ACell>
      Parameters:
      elements - Elements to include
      Returns:
      Updated set
    • reverseOp

      protected final int reverseOp(int setOp)
    • applyOp

      protected final Ref<T> applyOp(int setOp, Ref<T> a, Ref<T> b)
    • applySelf

      protected final AHashSet<T> applySelf(int setOp)
    • intersectAll

      public ASet<T> intersectAll(ASet<T> elements)
      Description copied from class: ASet
      Returns the intersection of two sets
      Specified by:
      intersectAll in class ASet<T extends ACell>
      Parameters:
      elements - Set to intersect with
      Returns:
      Intersection of the two sets
    • excludeAll

      public ASet<T> excludeAll(ASet<T> elements)
      Description copied from class: ASet
      Updates the set to exclude all the given elements.
      Specified by:
      excludeAll in class ASet<T extends ACell>
      Parameters:
      elements - Elements to exclude
      Returns:
      Updated set
    • toCanonical

      public abstract AHashSet<T> toCanonical()
      Description copied from class: ACell
      Converts this Cell to its canonical version. Must return this Cell if already canonical, may be O(n) in size of value otherwise.
      Specified by:
      toCanonical in class ACell
      Returns:
      Canonical version of Cell
    • conjAll

      public <R extends ACell> ASet<R> conjAll(ACollection<R> elements)
      Description copied from class: ADataStructure
      Adds multiple elements to this data structure, in the natural manner defined by the general data structure type. e.g. append at the end of a vector. This may be more efficient than using 'conj' for individual items.
      Specified by:
      conjAll in class ASet<T extends ACell>
      Type Parameters:
      R - Type of Value added
      Parameters:
      elements - New elements to add
      Returns:
      The updated data structure, or null if a failure occurred due to invalid elementtypes
    • disjAll

      public ASet<T> disjAll(ACollection<T> b)
      Description copied from class: ASet
      Removes all elements from this set, returning a new set.
      Specified by:
      disjAll in class ASet<T extends ACell>
      Parameters:
      b - Collection of elements to remove
      Returns:
      Set with specified element(s) removed
    • excludeRef

      public abstract AHashSet<T> excludeRef(Ref<T> valueRef)
    • includeRef

      public abstract AHashSet<T> includeRef(Ref<T> ref)
      Description copied from class: ASet
      Adds a value to this set using a Ref to the value
      Specified by:
      includeRef in class ASet<T extends ACell>
      Parameters:
      ref - Ref to value to include
      Returns:
      Updated set
    • conj

      public <R extends ACell> AHashSet<R> conj(R a)
      Description copied from class: ACollection
      Adds an element to this collection, according to the natural semantics of the collection
      Specified by:
      conj in class ASet<T extends ACell>
      Type Parameters:
      R - Type of Value added
      Parameters:
      a - Value to add, should be the element type of the data structure
      Returns:
      The updated collection
    • exclude

      public ASet<T> exclude(T a)
      Description copied from class: ASet
      Updates the set to exclude the given element
      Specified by:
      exclude in class ASet<T extends ACell>
      Parameters:
      a - Value to exclude
      Returns:
      Updated set
    • include

      public <R extends ACell> AHashSet<R> include(R a)
      Description copied from class: ASet
      Updates the set to include the given element
      Specified by:
      include in class ASet<T extends ACell>
      Parameters:
      a - Value to include
      Returns:
      Updated set
    • validateWithPrefix

      protected abstract void validateWithPrefix(Hash prefix, int digit, int position) throws InvalidDataException
      Validates the set with a given hex prefix. This is necessary to ensure that child maps are valid, in particular have the correct shift level and that all hashes start with the correct prefix of hex characters.
      Parameters:
      prefix - Hash for earlier prefix values
      digit - Hex digit expected at position [shift]
      Throws:
      InvalidDataException
    • toArray

      public Object[] toArray()
    • get

      public final CVMBool get(ACell key)
      Description copied from class: ADataStructure
      Get the value associated with a given key.
      Overrides:
      get in class ASet<T extends ACell>
      Parameters:
      key - Associative key to look up
      Returns:
      Value from collection, or a falsey value (null or false) if not found
    • getByHash

      public T getByHash(Hash hash)
      Gets the Value in the set for the given hash, or null if not found
      Parameters:
      hash - Hash of value to check in set
      Returns:
      The Value for the given Hash if found, null otherwise.
    • includeRef

      protected abstract AHashSet<T> includeRef(Ref<T> e, int i)
    • containsHash

      public abstract boolean containsHash(Hash hash)
      Tests if this Set contains a given hash
      Parameters:
      hash - Hash to test for set membership
      Returns:
      True if set contains value for given hash, false otherwise
    • contains

      public boolean contains(ACell key)
      Description copied from class: ASet
      Tests if this Set contains a given value
      Specified by:
      contains in class ASet<T extends ACell>
      Parameters:
      key - Value to test for set membership
      Returns:
      True if set contains value, false otherwise