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(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>, K extends ACell, V extends ACell> R of(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>, K extends ACell, V extends ACell> R create(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
public static <K extends ACell, V extends ACell> AHashMap<K,V> create(List<MapEntry<K,V>> entries)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 BadFormatExceptionRead 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
-