Package convex.core.data
Class Maps
java.lang.Object
convex.core.data.Maps
Utility class for map functions
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionConstructs a map with the given keys and values.Create a map with a collection of entries.create
(K k, V v) createWithShift
(int shift, List<MapEntry<K, V>> entries) Create a hashmap with the correct shift and given entries.empty()
emptyRef()
static <K,
V> HashMap<K, V> Constructs a map with the given keys and values.Read a Hashmap from a Blob.read
(ByteBuffer bb) Read a Hashmap from a ByteBuffer.
-
Field Details
-
MAX_ENCODING_SIZE
public static int MAX_ENCODING_SIZE
-
-
Constructor Details
-
Maps
public Maps()
-
-
Method Details
-
empty
-
emptyRef
-
create
-
of
public static <R extends AHashMap<K,V>, R ofK extends ACell, V extends ACell> (Object... keysAndValues) Constructs a map with the given keys and values. If keys are repreated, later keys will overwrite earlier ones. Performs conversion to CVM types.- Type Parameters:
R
- Map typeK
- Key typeV
- Value type- Parameters:
keysAndValues
- Keys and values to include- Returns:
- Map with given keys and values
-
create
public static <R extends AHashMap<K,V>, R createK extends ACell, V extends ACell> (ACell[] keysAndValues) Constructs a map with the given keys and values. If keys are repreated, later keys will overwrite earlier ones. Performs conversion to CVM types.- Type Parameters:
R
- Map typeK
- Key typeV
- Value type- Parameters:
keysAndValues
- Keys and values to include- Returns:
- Map with given keys and values
-
hashMapOf
-
create
Create a map with a collection of entries.- Type Parameters:
K
- Key typeV
- Value type- Parameters:
entries
- Entries to include- Returns:
- AHashMap instance
-
createWithShift
public static <K extends ACell,V extends ACell> AHashMap<K,V> createWithShift(int shift, List<MapEntry<K, V>> entries) Create a hashmap with the correct shift and given entries.- Type Parameters:
K
- Key typeV
- Value type- Parameters:
shift
- Shift level of mapentries
- Entries to include- Returns:
- AHashMap instance
-
coerce
-
read
public static <K extends ACell,V extends ACell> AHashMap<K,V> read(ByteBuffer bb) throws BadFormatException Read a Hashmap from a ByteBuffer. Assumes tag byte already read.- Type Parameters:
K
- Key typeV
- Value type- Parameters:
bb
- ByteBuffer to read from- Returns:
- Map instance
- Throws:
BadFormatException
- If encoding is invalid
-
read
public static <K extends ACell,V extends ACell> AHashMap<K,V> read(Blob b, int pos) throws BadFormatException Read a Hashmap from a Blob. Assumes tag byte already read and at position specified- Type Parameters:
K
- Key typeV
- Value type- Parameters:
b
- ByteBuffer to read frompos
- Position to read from Blob (tag location)- Returns:
- Map instance
- Throws:
BadFormatException
- If encoding is invalid
-