Package qilin.util

Class ArrayNumberer<E extends Numberable>

java.lang.Object
qilin.util.ArrayNumberer<E>
All Implemented Interfaces:
Iterable<E>, IterableNumberer<E>, Numberer<E>
Direct Known Subclasses:
StringNumberer

public class ArrayNumberer<E extends Numberable> extends Object implements IterableNumberer<E>
A class that numbers objects, so they can be placed in bitsets.
Author:
Ondrej Lhotak, xiao, generalize it.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected BitSet
     
    protected int
     
    protected E[]
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    ArrayNumberer(E[] elements)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(E o)
    Tells the numberer that a new object needs to be assigned a number.
    get(long number)
    Should return the object that was assigned the number.
    long
    get(E o)
    Should return the number that was assigned to object o that was previously passed as an argument to add().
    Returns an iterator over all objects added to the numberer.
    boolean
    remove(E o)
    Removes the number for a given object.
    int
    Should return the number of objects that have been assigned numbers.

    Methods inherited from class java.lang.Object

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

    Methods inherited from interface java.lang.Iterable

    forEach, spliterator
  • Field Details

    • numberToObj

      protected E extends Numberable[] numberToObj
    • lastNumber

      protected int lastNumber
    • freeNumbers

      protected BitSet freeNumbers
  • Constructor Details

    • ArrayNumberer

      public ArrayNumberer()
    • ArrayNumberer

      public ArrayNumberer(E[] elements)
  • Method Details

    • add

      public void add(E o)
      Description copied from interface: Numberer
      Tells the numberer that a new object needs to be assigned a number.
      Specified by:
      add in interface Numberer<E extends Numberable>
    • get

      public long get(E o)
      Description copied from interface: Numberer
      Should return the number that was assigned to object o that was previously passed as an argument to add().
      Specified by:
      get in interface Numberer<E extends Numberable>
    • get

      public E get(long number)
      Description copied from interface: Numberer
      Should return the object that was assigned the number.
      Specified by:
      get in interface Numberer<E extends Numberable>
    • size

      public int size()
      Description copied from interface: Numberer
      Should return the number of objects that have been assigned numbers.
      Specified by:
      size in interface Numberer<E extends Numberable>
    • iterator

      public Iterator<E> iterator()
      Description copied from interface: IterableNumberer
      Returns an iterator over all objects added to the numberer.
      Specified by:
      iterator in interface Iterable<E extends Numberable>
      Specified by:
      iterator in interface IterableNumberer<E extends Numberable>
    • remove

      public boolean remove(E o)
      Description copied from interface: Numberer
      Removes the number for a given object.
      Specified by:
      remove in interface Numberer<E extends Numberable>
      Parameters:
      o - the element
      Returns:
      true if the removal was successful, false when not