Package eu.simuline.util
Class BitSetList
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<Integer>
-
- eu.simuline.util.BitSetList
-
public final class BitSetList extends AbstractList<Integer> implements Cloneable
Implements a list of integers0and1stored as bits in aBitSet.Implementational note:
EextendsIntegerwhich in turn is final. This meansEis nothing butInteger. Created: Mon May 29 19:37:38 2006- Version:
- 1.0
- Author:
- Ernst Reissner
-
-
Field Summary
Fields Modifier and Type Field Description private intsizeprivate BitSetwrapped-
Fields inherited from class java.util.AbstractList
modCount
-
-
Constructor Summary
Constructors Constructor Description BitSetList()Creates a newBitSetListinstance.BitSetList(int initialCapacity)BitSetList(Collection<? extends Integer> coll)Creates a newBitSetListinstance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(int index, Integer integer)Describeaddmethod here.private static Integerbool2int(boolean bool)Returns the C-representation of the givenbooleanas anint.intcardinality()voidclear()Describeclearmethod here.BitSetListclone()booleancontains(Object object)Describecontainsmethod here.booleanequals(Object other)Integerget(int index)Describegetmethod here.inthashCode()Returns the hash code value for this cyclic list.private static booleanint2bool(int num)Converts the given C-style-representation of aboolean.intlength1()Returns the "logical size" of this List: The index of the highest digit1in the List plus one.Integerremove(int index)Describeremovemethod here.booleanremove(Object object)Describeremovemethod here.Integerset(int index, Integer integer)Describesetmethod here.voidsetW(int index)intsize()Describesizemethod here.intsizeInternally()-
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.util.List
addAll, containsAll, isEmpty, removeAll, replaceAll, retainAll, sort, spliterator, toArray, toArray
-
-
-
-
Field Detail
-
wrapped
private BitSet wrapped
-
size
private int size
-
-
Constructor Detail
-
BitSetList
public BitSetList()
Creates a newBitSetListinstance.
-
BitSetList
public BitSetList(Collection<? extends Integer> coll)
Creates a newBitSetListinstance.- Parameters:
coll- a collection which may not containnullpointers.- Throws:
NullPointerException- ifcollcontains anullpointer.IllegalArgumentException- ifcollcontains anIntegerobject other than0or1.
-
BitSetList
public BitSetList(int initialCapacity)
-
-
Method Detail
-
bool2int
private static Integer bool2int(boolean bool)
Returns the C-representation of the givenbooleanas anint.- Parameters:
bool- abooleanvalue.- Returns:
- an
intrepresentation ofbool:-
1ifbool == true. -
0ifbool == false.
-
- See Also:
int2bool(int)
-
int2bool
private static boolean int2bool(int num)
Converts the given C-style-representation of aboolean.- Returns:
- an
boolrepresentation ofnum:-
trueifnum == 1. -
falseifnum == 0.
-
- Throws:
IllegalArgumentException- ifnumis neither0nor1.- 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 digit1in the List plus one. Returns zero if the List contains0'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 thatlist1.equals(list2)implies thatlist1.hashCode()==list2.hashCode()for any two lists,list1andlist2, as required by the general contract ofObject.hashCode.Note that this list does not allow null-elements and the hash code of an element is its value.
- Specified by:
hashCodein interfaceCollection<Integer>- Specified by:
hashCodein interfaceList<Integer>- Overrides:
hashCodein classAbstractList<Integer>- Returns:
- the hash code value for this list.
- See Also:
List.hashCode(),Object.equals(Object),equals(Object)
-
equals
public boolean equals(Object other)
- Specified by:
equalsin interfaceCollection<Integer>- Specified by:
equalsin interfaceList<Integer>- Overrides:
equalsin classAbstractList<Integer>
-
add
public void add(int index, Integer integer)Describeaddmethod here.
-
clear
public void clear()
Describeclearmethod here.- Specified by:
clearin interfaceCollection<Integer>- Specified by:
clearin interfaceList<Integer>- Overrides:
clearin classAbstractList<Integer>
-
contains
public boolean contains(Object object)
Describecontainsmethod here.- Specified by:
containsin interfaceCollection<Integer>- Specified by:
containsin interfaceList<Integer>- Overrides:
containsin classAbstractCollection<Integer>- Parameters:
object- anObjectvalue- Returns:
- a
booleanvalue
-
get
public Integer get(int index)
Describegetmethod here.
-
size
public int size()
Describesizemethod here.- Specified by:
sizein interfaceCollection<Integer>- Specified by:
sizein interfaceList<Integer>- Specified by:
sizein classAbstractCollection<Integer>- Returns:
- an
intvalue
-
remove
public boolean remove(Object object)
Describeremovemethod here.- Specified by:
removein interfaceCollection<Integer>- Specified by:
removein interfaceList<Integer>- Overrides:
removein classAbstractCollection<Integer>- Parameters:
object- theObjectto be removed, if present.- Returns:
- the
booleanvaluetrueif this list contained the specified element.
-
remove
public Integer remove(int index)
Describeremovemethod here.
-
clone
public BitSetList clone() throws CloneNotSupportedException
- Overrides:
clonein classObject- Throws:
CloneNotSupportedException
-
-