java.io.Serializable
, java.lang.Cloneable
public class OtpErlangMap extends OtpErlangObject
The arity of the map is the number of elements it contains. The keys and values can be retrieved as arrays and the value for a key can be queried.
OtpErlangObject.Hash
hashCodeValue
Constructor | Description |
---|---|
OtpErlangMap() |
Create an empty map.
|
OtpErlangMap(OtpErlangObject[] keys,
int kstart,
int kcount,
OtpErlangObject[] values,
int vstart,
int vcount) |
Create a map from an array of terms.
|
OtpErlangMap(OtpErlangObject[] keys,
OtpErlangObject[] values) |
Create a map from an array of keys and an array of values.
|
OtpErlangMap(OtpInputStream buf) |
Create a map from a stream containing a map encoded in Erlang external
format.
|
Modifier and Type | Method | Description |
---|---|---|
int |
arity() |
Get the arity of the map.
|
<T> OtpErlangObject |
bind(T binds) |
Make new Erlang term replacing variables with the respective values from
bindings argument(s).
|
java.lang.Object |
clone() |
|
protected int |
doHashCode() |
|
void |
encode(OtpOutputStream buf) |
Convert this map to the equivalent Erlang external representation.
|
java.util.Set<java.util.Map.Entry<OtpErlangObject,OtpErlangObject>> |
entrySet() |
make Set view of the map key-value pairs
|
boolean |
equals(java.lang.Object o) |
Determine if two maps are equal.
|
OtpErlangObject |
get(OtpErlangObject key) |
Get the specified value from the map.
|
OtpErlangObject[] |
keys() |
Get all the keys from the map as an array.
|
<T> boolean |
match(OtpErlangObject term,
T binds) |
Perform match operation against given term.
|
OtpErlangObject |
put(OtpErlangObject key,
OtpErlangObject value) |
Put value corresponding to key into the map.
|
OtpErlangObject |
remove(OtpErlangObject key) |
removes mapping for the key if present.
|
java.lang.String |
toString() |
Get the string representation of the map.
|
OtpErlangObject[] |
values() |
Get all the values from the map as an array.
|
finalize, getClass, notify, notifyAll, wait, wait, wait
decode, hashCode
public OtpErlangMap()
public OtpErlangMap(OtpErlangObject[] keys, OtpErlangObject[] values)
keys
- the array of terms to create the map keys from.values
- the array of terms to create the map values from.java.lang.IllegalArgumentException
- if any array is empty (null) or contains null elements.public OtpErlangMap(OtpErlangObject[] keys, int kstart, int kcount, OtpErlangObject[] values, int vstart, int vcount)
keys
- the array of terms to create the map from.kstart
- the offset of the first key to insert.kcount
- the number of keys to insert.values
- the array of values to create the map from.vstart
- the offset of the first value to insert.vcount
- the number of values to insert.java.lang.IllegalArgumentException
- if any array is empty (null) or contains null elements.java.lang.IllegalArgumentException
- if kcount and vcount differ.public OtpErlangMap(OtpInputStream buf) throws OtpErlangDecodeException
buf
- the stream containing the encoded map.OtpErlangDecodeException
- if the buffer does not contain a valid external
representation of an Erlang map.public int arity()
public OtpErlangObject put(OtpErlangObject key, OtpErlangObject value)
Map.put(Object, Object)
.key
- key to associate value withvalue
- value to associate with keypublic OtpErlangObject remove(OtpErlangObject key)
key
- key for which mapping is to be removepublic OtpErlangObject get(OtpErlangObject key)
key
- the key of the requested value.public OtpErlangObject[] keys()
public OtpErlangObject[] values()
public java.util.Set<java.util.Map.Entry<OtpErlangObject,OtpErlangObject>> entrySet()
public java.lang.String toString()
toString
in class OtpErlangObject
public void encode(OtpOutputStream buf)
encode
in class OtpErlangObject
buf
- an output stream to which the encoded map should be written.public boolean equals(java.lang.Object o)
equals
in class OtpErlangObject
o
- the map to compare to.public <T> boolean match(OtpErlangObject term, T binds)
OtpErlangObject
match
in class OtpErlangObject
term
- the object to matchbinds
- variable bindingspublic <T> OtpErlangObject bind(T binds) throws OtpErlangException
OtpErlangObject
bind
in class OtpErlangObject
binds
- variable bindingsOtpErlangException
protected int doHashCode()
doHashCode
in class OtpErlangObject
public java.lang.Object clone()
clone
in class OtpErlangObject