Package cds.moc
Class IntArray
- java.lang.Object
-
- cds.moc.Array
-
- cds.moc.IntArray
-
- All Implemented Interfaces:
java.lang.Cloneable,java.lang.Iterable<java.lang.Long>
public final class IntArray extends Array
Fast array of integers
-
-
Field Summary
-
Fields inherited from class cds.moc.Array
DEFAULTBLOC, size, sizeBloc, sorted
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(int v, boolean testUnicity)booleanadd(long v, boolean testUnicity)Add a long.Arrayclone()Deep copybooleandelete(int v)booleandelete(int v1, int v2)booleandelete(long v)Delete the first value equals to v kept the array sorted if requiredbooleandelete(long v1, long v2)Delete the all values between v1 and v2 (inclusive) kept the array sorted if requiredbooleandeleteBrothers(int me)booleandeleteBrothers(long me)Delete three other brothers only of all of them are already present (apart me)booleanequals(Array a)Equality testintfind(int v)intfind(long v)Return the index of the first value v.longget(int i)Provide the element ilonggetMem()Size of the array in bytesintgetSizeCompressed()Size of the array in compressed mode => consecutive values are memorized as range (2 values)booleanintersectRange(int vStart, int vEnd)booleanintersectRange(long vStart, long vEnd)Return true if at least one value of the range [vStart..vEnd] (included) is found in the arrayint[]seeArray()Provide the java reference on the array (real size is provided by getSize() and not by .length)voidset(int i, long v)set the element ivoidsort()Sort the array (only if required)voidtrim()Remove the reservation room in the array
-
-
-
Method Detail
-
seeArray
public int[] seeArray()
Provide the java reference on the array (real size is provided by getSize() and not by .length)- Returns:
- array of longs
-
get
public long get(int i)
Description copied from class:ArrayProvide the element i
-
set
public void set(int i, long v)Description copied from class:Arrayset the element i
-
getSizeCompressed
public int getSizeCompressed()
Size of the array in compressed mode => consecutive values are memorized as range (2 values)- Specified by:
getSizeCompressedin classArray- Returns:
- Number of values
-
add
public boolean add(long v, boolean testUnicity)Add a long. the array will be automatically extended if necessary
-
add
public boolean add(int v, boolean testUnicity)
-
delete
public boolean delete(long v)
Delete the first value equals to v kept the array sorted if required
-
delete
public boolean delete(int v)
-
delete
public boolean delete(long v1, long v2)Delete the all values between v1 and v2 (inclusive) kept the array sorted if required
-
delete
public boolean delete(int v1, int v2)
-
deleteBrothers
public boolean deleteBrothers(long me)
Delete three other brothers only of all of them are already present (apart me)- Specified by:
deleteBrothersin classArray- Returns:
- false if not found
-
deleteBrothers
public boolean deleteBrothers(int me)
-
find
public int find(long v)
Return the index of the first value v. -1 if not found. If the arrays is sorted, proceeds by bsearch (see bsearch doc)
-
find
public int find(int v)
-
intersectRange
public boolean intersectRange(long vStart, long vEnd)Return true if at least one value of the range [vStart..vEnd] (included) is found in the array- Specified by:
intersectRangein classArray- Parameters:
vStart- range starting valuevEnd- range ending value- Returns:
- true in case of success
-
intersectRange
public boolean intersectRange(int vStart, int vEnd)
-
-