com.alexkasko.unsafe.offheaplong
public class LongPacker extends Object
OffHeapLongAddressable
.
Values are stored using bit shifting as follows:
0 32 64-bits 64
+-----------------------------+-----------+------------------+
| first 32 bits of long value | int value | tail of long val |
+-----------------------------+-----------+------------------+
This class doesn't use sun.misc.Unsafe
Constructor and Description |
---|
LongPacker() |
Modifier and Type | Method and Description |
---|---|
static long |
big(long pack,
int bits)
Read long value from packed long.
|
static int |
little(long pack,
int bits)
Values limits are checking using
assert
keyword, java must be run with -ea switch to enable them. |
static long |
pack(long big,
int little,
int bits)
Packs one long value with limited size and one int value
into one long value.
|
public LongPacker()
public static long pack(long big, int little, int bits)
assert
keyword, java must be run with -ea
switch to enable them.big
- long valuelittle
- int valuebits
- max size of long value in bits, max size of int value is 64 - bits
public static long big(long pack, int bits)
assert
keyword, java must be run with -ea
switch to enable them.pack
- packed longbits
- max size of long value in bits, max size of int value is 64 - bits
public static int little(long pack, int bits)
assert
keyword, java must be run with -ea
switch to enable them.pack
- packed longbits
- max size of long value in bits, max size of int value is 64 - bits
Copyright © 2014. All Rights Reserved.