Package eu.simuline.util
Class BitSetList
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<java.lang.Integer>
-
- eu.simuline.util.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.CloneableImplements 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
-
-
Constructor Summary
Constructors Constructor Description BitSetList()Creates a newBitSetListinstance.BitSetList(int initialCapacity)BitSetList(java.util.Collection<? extends java.lang.Integer> coll)Creates a newBitSetListinstance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(int index, java.lang.Integer integer)Describeaddmethod here.private static java.lang.Integerbool2int(boolean bool)Returns the C-representation of the givenbooleanas anint.intcardinality()voidclear()Describeclearmethod here.BitSetListclone()booleancontains(java.lang.Object object)Describecontainsmethod here.booleanequals(java.lang.Object other)java.lang.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.java.lang.Integerremove(int index)Describeremovemethod here.booleanremove(java.lang.Object object)Describeremovemethod here.java.lang.Integerset(int index, java.lang.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
-
-
-
-
Constructor Detail
-
BitSetList
public BitSetList()
Creates a newBitSetListinstance.
-
BitSetList
public BitSetList(java.util.Collection<? extends java.lang.Integer> coll)
Creates a newBitSetListinstance.- Parameters:
coll- a collection which may not containnullpointers.- Throws:
java.lang.NullPointerException- ifcollcontains anullpointer.java.lang.IllegalArgumentException- ifcollcontains anIntegerobject other than0or1.
-
BitSetList
public BitSetList(int initialCapacity)
-
-
Method Detail
-
bool2int
private static java.lang.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:
java.lang.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 interfacejava.util.Collection<java.lang.Integer>- Specified by:
hashCodein interfacejava.util.List<java.lang.Integer>- Overrides:
hashCodein classjava.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:
equalsin interfacejava.util.Collection<java.lang.Integer>- Specified by:
equalsin interfacejava.util.List<java.lang.Integer>- Overrides:
equalsin classjava.util.AbstractList<java.lang.Integer>
-
add
public void add(int index, java.lang.Integer integer)Describeaddmethod here.- Specified by:
addin interfacejava.util.List<java.lang.Integer>- Overrides:
addin classjava.util.AbstractList<java.lang.Integer>- Parameters:
index- anintvalueinteger- anIntegervalue
-
clear
public void clear()
Describeclearmethod here.- Specified by:
clearin interfacejava.util.Collection<java.lang.Integer>- Specified by:
clearin interfacejava.util.List<java.lang.Integer>- Overrides:
clearin classjava.util.AbstractList<java.lang.Integer>
-
contains
public boolean contains(java.lang.Object object)
Describecontainsmethod here.- Specified by:
containsin interfacejava.util.Collection<java.lang.Integer>- Specified by:
containsin interfacejava.util.List<java.lang.Integer>- Overrides:
containsin classjava.util.AbstractCollection<java.lang.Integer>- Parameters:
object- anObjectvalue- Returns:
- a
booleanvalue
-
get
public java.lang.Integer get(int index)
Describegetmethod here.- Specified by:
getin interfacejava.util.List<java.lang.Integer>- Specified by:
getin classjava.util.AbstractList<java.lang.Integer>- Parameters:
index- anintvalue- Returns:
- an
Objectvalue
-
size
public int size()
Describesizemethod here.- Specified by:
sizein interfacejava.util.Collection<java.lang.Integer>- Specified by:
sizein interfacejava.util.List<java.lang.Integer>- Specified by:
sizein classjava.util.AbstractCollection<java.lang.Integer>- Returns:
- an
intvalue
-
remove
public boolean remove(java.lang.Object object)
Describeremovemethod here.- Specified by:
removein interfacejava.util.Collection<java.lang.Integer>- Specified by:
removein interfacejava.util.List<java.lang.Integer>- Overrides:
removein classjava.util.AbstractCollection<java.lang.Integer>- Parameters:
object- theObjectto be removed, if present.- Returns:
- the
booleanvaluetrueif this list contained the specified element.
-
remove
public java.lang.Integer remove(int index)
Describeremovemethod here.- Specified by:
removein interfacejava.util.List<java.lang.Integer>- Overrides:
removein classjava.util.AbstractList<java.lang.Integer>- Parameters:
index- anintvalue- Returns:
- an
Objectvalue
-
set
public java.lang.Integer set(int index, java.lang.Integer integer)Describesetmethod here.- Specified by:
setin interfacejava.util.List<java.lang.Integer>- Overrides:
setin classjava.util.AbstractList<java.lang.Integer>- Parameters:
index- anintvalueinteger- anObjectvalue- Returns:
- an
Objectvalue
-
clone
public BitSetList clone() throws java.lang.CloneNotSupportedException
- Overrides:
clonein classjava.lang.Object- Throws:
java.lang.CloneNotSupportedException
-
-