Package org.eclipse.mat.collect
Class ArrayIntCompressed
- java.lang.Object
-
- org.eclipse.mat.collect.ArrayIntCompressed
-
public class ArrayIntCompressed extends Object
This class compresses fixed-size int[] in a very fast and memory efficient manner if many leading and/or trailing bits of the stored ints are not used commonly. The internal data is never copied during the process of retrieving or reconstructing objects of this class and allows for fast I/O writing and reading of the underlying byte[]. Furthermore almost no additional data is used beside the underlying byte[]. Thereby the memory consumption of this data structure is kept at a minimum to build efficient int[] caches.
-
-
Constructor Summary
Constructors Constructor Description ArrayIntCompressed(byte[] bytes)
CreateIntArrayCompressed
from bytes formerly got fromtoByteArray()
.ArrayIntCompressed(int[] ints)
CreateIntArrayCompressed
from ints representing the data to be stored in compressed form.ArrayIntCompressed(int[] ints, int offset, int length)
CreateIntArrayCompressed
from ints representing the data to be stored in compressed form (from offset to offset+length).ArrayIntCompressed(int size, int leadingClearBits, int trailingClearBits)
CreateIntArrayCompressed
from number of ints to be stored, the number of leading and trailing clear bits.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
get(int index)
Get value from the given index.void
set(int index, int value)
Set value at the given index.byte[]
toByteArray()
Get bytes representing the internal data structure with which anIntArrayCompressed
can be reconstructed.
-
-
-
Constructor Detail
-
ArrayIntCompressed
public ArrayIntCompressed(byte[] bytes)
CreateIntArrayCompressed
from bytes formerly got fromtoByteArray()
.- Parameters:
bytes
- bytes formerly got fromtoByteArray()
-
ArrayIntCompressed
public ArrayIntCompressed(int size, int leadingClearBits, int trailingClearBits)
CreateIntArrayCompressed
from number of ints to be stored, the number of leading and trailing clear bits. Everything else is stored in the internal data structure.- Parameters:
size
- number of ints to be storedleadingClearBits
- number of leading clear bitstrailingClearBits
- number of trailing clear bits
-
ArrayIntCompressed
public ArrayIntCompressed(int[] ints)
CreateIntArrayCompressed
from ints representing the data to be stored in compressed form.- Parameters:
ints
- ints representing the data to be stored in compressed form
-
ArrayIntCompressed
public ArrayIntCompressed(int[] ints, int offset, int length)
CreateIntArrayCompressed
from ints representing the data to be stored in compressed form (from offset to offset+length).- Parameters:
ints
- ints representing the data to be stored in compressed formoffset
- offset from which on to compress the intslength
- number of ints to compress from the given array
-
-
Method Detail
-
set
public void set(int index, int value)
Set value at the given index.- Parameters:
index
- index at which the value should be setvalue
- value to be set at the given index
-
get
public int get(int index)
Get value from the given index.- Parameters:
index
- index at which the value should be set- Returns:
- value found at the given index
-
toByteArray
public byte[] toByteArray()
Get bytes representing the internal data structure with which anIntArrayCompressed
can be reconstructed.- Returns:
- bytes representing the internal data structure with which an
IntArrayCompressed
can be reconstructed
-
-