Package cds.moc
Class ShortArray
- java.lang.Object
-
- cds.moc.Array
-
- cds.moc.ShortArray
-
- All Implemented Interfaces:
java.lang.Cloneable
,java.lang.Iterable<java.lang.Long>
public final class ShortArray extends Array
Fast array of shorts
-
-
Field Summary
-
Fields inherited from class cds.moc.Array
DEFAULTBLOC, size, sizeBloc, sorted
-
-
Constructor Summary
Constructors Constructor Description ShortArray(int bloc)
Create a free array of longsShortArray(short[] v)
Create an array of integers initializing with v[]
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(long v, boolean testUnicity)
Add a long.boolean
add(short v, boolean testUnicity)
Array
clone()
Deep copyboolean
delete(long v)
Delete the first value equals to v kept the array sorted if requiredboolean
delete(long v1, long v2)
Delete the all values between v1 and v2 (inclusive) kept the array sorted if requiredboolean
delete(short v)
boolean
delete(short v1, short v2)
boolean
deleteBrothers(long me)
Delete three other brothers only of all of them are already present (apart me)boolean
deleteBrothers(short me)
boolean
equals(Array a)
Equality testint
find(long v)
Return the index of the first value v.int
find(short v)
int
geSize()
long
get(int i)
Provide the element ilong
getMem()
Size of the array in bytesint
getSizeCompressed()
Size of the array in compressed mode => consecutive values are memorized as range (2 values)boolean
intersectRange(long vStart, long vEnd)
Return true if at least one value of the range [vStart..vEnd] (included) is found in the arrayboolean
intersectRange(short vStart, short vEnd)
short[]
seeArray()
Provide the java reference on the array (real size is provided by getSize() and not by .length)void
set(int i, long v)
set the element ivoid
sort()
Sort the array (only if required)void
trim()
Remove the reservation room in the array
-
-
-
Method Detail
-
seeArray
public short[] 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:Array
Provide the element i
-
set
public void set(int i, long v)
Description copied from class:Array
set the element i
-
geSize
public int geSize()
-
getSizeCompressed
public int getSizeCompressed()
Size of the array in compressed mode => consecutive values are memorized as range (2 values)- Specified by:
getSizeCompressed
in 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(short 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(short 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(short v1, short v2)
-
deleteBrothers
public boolean deleteBrothers(long me)
Delete three other brothers only of all of them are already present (apart me)- Specified by:
deleteBrothers
in classArray
- Returns:
- false if not found
-
deleteBrothers
public boolean deleteBrothers(short 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(short 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:
intersectRange
in classArray
- Parameters:
vStart
- range starting valuevEnd
- range ending value- Returns:
- true in case of success
-
intersectRange
public boolean intersectRange(short vStart, short vEnd)
-
-