Class BitSetList

  • All Implemented Interfaces:
    java.lang.Cloneable, java.lang.Iterable<java.lang.Integer>, java.util.Collection<java.lang.Integer>, java.util.List<java.lang.Integer>

    public final class BitSetList
    extends java.util.AbstractList<java.lang.Integer>
    implements java.lang.Cloneable
    Implements a list of integers 0 and 1 stored as bits in a BitSet.

    Implementational note: E extends Integer which in turn is final. This means E is nothing but Integer. Created: Mon May 29 19:37:38 2006

    Version:
    1.0
    Author:
    Ernst Reissner
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private int size  
      private java.util.BitSet wrapped  
      • Fields inherited from class java.util.AbstractList

        modCount
    • Constructor Summary

      Constructors 
      Constructor Description
      BitSetList()
      Creates a new BitSetList instance.
      BitSetList​(int initialCapacity)  
      BitSetList​(java.util.Collection<? extends java.lang.Integer> coll)
      Creates a new BitSetList instance.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(int index, java.lang.Integer integer)
      Describe add method here.
      private static java.lang.Integer bool2int​(boolean bool)
      Returns the C-representation of the given boolean as an int.
      int cardinality()  
      void clear()
      Describe clear method here.
      BitSetList clone()  
      boolean contains​(java.lang.Object object)
      Describe contains method here.
      boolean equals​(java.lang.Object other)  
      java.lang.Integer get​(int index)
      Describe get method here.
      int hashCode()
      Returns the hash code value for this cyclic list.
      private static boolean int2bool​(int num)
      Converts the given C-style-representation of a boolean.
      int length1()
      Returns the "logical size" of this List: The index of the highest digit 1 in the List plus one.
      java.lang.Integer remove​(int index)
      Describe remove method here.
      boolean remove​(java.lang.Object object)
      Describe remove method here.
      java.lang.Integer set​(int index, java.lang.Integer integer)
      Describe set method here.
      void setW​(int index)  
      int size()
      Describe size method here.
      int sizeInternally()  
      • Methods inherited from class java.util.AbstractList

        add, addAll, indexOf, iterator, lastIndexOf, listIterator, listIterator, removeRange, subList
      • Methods inherited from class java.util.AbstractCollection

        addAll, containsAll, isEmpty, removeAll, retainAll, toArray, toArray, toString
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
      • 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.List

        addAll, containsAll, isEmpty, removeAll, replaceAll, retainAll, sort, spliterator, toArray, toArray
    • Field Detail

      • wrapped

        private java.util.BitSet wrapped
      • size

        private int size
    • Constructor Detail

      • BitSetList

        public BitSetList()
        Creates a new BitSetList instance.
      • BitSetList

        public BitSetList​(java.util.Collection<? extends java.lang.Integer> coll)
        Creates a new BitSetList instance.
        Parameters:
        coll - a collection which may not contain null pointers.
        Throws:
        java.lang.NullPointerException - if coll contains a null pointer.
        java.lang.IllegalArgumentException - if coll contains an Integer object other than 0 or 1.
      • BitSetList

        public BitSetList​(int initialCapacity)
    • Method Detail

      • bool2int

        private static java.lang.Integer bool2int​(boolean bool)
        Returns the C-representation of the given boolean as an int.
        Parameters:
        bool - a boolean value.
        Returns:
        an int representation of bool:
        • 1 if bool == true .
        • 0 if bool == false.
        See Also:
        int2bool(int)
      • int2bool

        private static boolean int2bool​(int num)
        Converts the given C-style-representation of a boolean.
        Returns:
        an bool representation of num:
        • true if num == 1.
        • false if num == 0.
        Throws:
        java.lang.IllegalArgumentException - if num is neither 0 nor 1.
        See Also:
        bool2int(boolean)
      • cardinality

        public int cardinality()
      • sizeInternally

        public int sizeInternally()
      • length1

        public int length1()
        Returns the "logical size" of this List: The index of the highest digit 1 in the List plus one. Returns zero if the List contains 0's only.
        Returns:
        the logical size of this List.
      • setW

        public void setW​(int index)
      • hashCode

        public int hashCode()
        Returns the hash code value for this cyclic list. The hash code of a list is defined to be the result of the following calculation:
          hashCode = 1;
          Iterator i = list.iterator();
          while (i.hasNext()) {
              Object obj = i.next();
              hashCode = 31*hashCode + (obj==null ? 0 : obj.hashCode());
          }
         
        This ensures that list1.equals(list2) implies that list1.hashCode()==list2.hashCode() for any two lists, list1 and list2, as required by the general contract of Object.hashCode.

        Note that this list does not allow null-elements and the hash code of an element is its value.

        Specified by:
        hashCode in interface java.util.Collection<java.lang.Integer>
        Specified by:
        hashCode in interface java.util.List<java.lang.Integer>
        Overrides:
        hashCode in class java.util.AbstractList<java.lang.Integer>
        Returns:
        the hash code value for this list.
        See Also:
        List.hashCode(), Object.equals(Object), equals(Object)
      • equals

        public boolean equals​(java.lang.Object other)
        Specified by:
        equals in interface java.util.Collection<java.lang.Integer>
        Specified by:
        equals in interface java.util.List<java.lang.Integer>
        Overrides:
        equals in class java.util.AbstractList<java.lang.Integer>
      • add

        public void add​(int index,
                        java.lang.Integer integer)
        Describe add method here.
        Specified by:
        add in interface java.util.List<java.lang.Integer>
        Overrides:
        add in class java.util.AbstractList<java.lang.Integer>
        Parameters:
        index - an int value
        integer - an Integer value
      • clear

        public void clear()
        Describe clear method here.
        Specified by:
        clear in interface java.util.Collection<java.lang.Integer>
        Specified by:
        clear in interface java.util.List<java.lang.Integer>
        Overrides:
        clear in class java.util.AbstractList<java.lang.Integer>
      • contains

        public boolean contains​(java.lang.Object object)
        Describe contains method here.
        Specified by:
        contains in interface java.util.Collection<java.lang.Integer>
        Specified by:
        contains in interface java.util.List<java.lang.Integer>
        Overrides:
        contains in class java.util.AbstractCollection<java.lang.Integer>
        Parameters:
        object - an Object value
        Returns:
        a boolean value
      • get

        public java.lang.Integer get​(int index)
        Describe get method here.
        Specified by:
        get in interface java.util.List<java.lang.Integer>
        Specified by:
        get in class java.util.AbstractList<java.lang.Integer>
        Parameters:
        index - an int value
        Returns:
        an Object value
      • size

        public int size()
        Describe size method here.
        Specified by:
        size in interface java.util.Collection<java.lang.Integer>
        Specified by:
        size in interface java.util.List<java.lang.Integer>
        Specified by:
        size in class java.util.AbstractCollection<java.lang.Integer>
        Returns:
        an int value
      • remove

        public boolean remove​(java.lang.Object object)
        Describe remove method here.
        Specified by:
        remove in interface java.util.Collection<java.lang.Integer>
        Specified by:
        remove in interface java.util.List<java.lang.Integer>
        Overrides:
        remove in class java.util.AbstractCollection<java.lang.Integer>
        Parameters:
        object - the Object to be removed, if present.
        Returns:
        the boolean value true if this list contained the specified element.
      • remove

        public java.lang.Integer remove​(int index)
        Describe remove method here.
        Specified by:
        remove in interface java.util.List<java.lang.Integer>
        Overrides:
        remove in class java.util.AbstractList<java.lang.Integer>
        Parameters:
        index - an int value
        Returns:
        an Object value
      • set

        public java.lang.Integer set​(int index,
                                     java.lang.Integer integer)
        Describe set method here.
        Specified by:
        set in interface java.util.List<java.lang.Integer>
        Overrides:
        set in class java.util.AbstractList<java.lang.Integer>
        Parameters:
        index - an int value
        integer - an Object value
        Returns:
        an Object value
      • clone

        public BitSetList clone()
                         throws java.lang.CloneNotSupportedException
        Overrides:
        clone in class java.lang.Object
        Throws:
        java.lang.CloneNotSupportedException