Enfusion Script API
Loading...
Searching...
No Matches
Public Member Functions | List of all members
map< Class TKey, Class TValue > Interface Template Reference

Associative array template. More...

Inheritance diagram for map< Class TKey, Class TValue >:
[legend]

Public Member Functions

proto native int Count ()
 
proto native bool IsEmpty ()
 
proto native void Clear ()
 Clears the map.
 
proto TValue Get (TKey key)
 Search for an element with the given key.
 
proto bool Find (TKey key, out TValue val)
 Search for an element with the given key.
 
proto TValue GetElement (int index)
 Return the i-th element in the map.
 
proto TKey GetKey (int i)
 Return the i-th element key in the map.
 
proto void Set (TKey key, TValue value)
 Sets value of element with given key.
 
proto bool Remove (TKey key)
 
proto bool Take (TKey key, out TValue value)
 Search for an element with the given key and remove it.
 
proto bool RemoveElement (int i)
 Removes i-th element with given key.
 
proto bool Contains (TKey key)
 Returns whether map contains element with given key.
 
proto bool Insert (TKey key, TValue value)
 Insert new element into map.
 
proto int Copy (map< TKey, TValue > from)
 
bool ReplaceKey (TKey old_key, TKey new_key)
 
TKey GetKeyByValue (TValue value)
 
proto native MapIterator Begin ()
 
proto native MapIterator End ()
 
proto native MapIterator Next (MapIterator it)
 
proto TKey GetIteratorKey (MapIterator it)
 
proto TValue GetIteratorElement (MapIterator it)
 
- Public Member Functions inherited from Managed
proto external ref Managed Clone ()
 Return shallow copy of object, or null if it is not allowed (not public constructor)
 

Detailed Description

Associative array template.

Usage:

// fill
prg_count.Insert("hello", 10);
prg_count.Insert("world", 20);
prg_count.Insert("!", 1);
Print(prg_count.Get("world")); // prints '20'
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
Associative array template.
Definition: Types.c:481
proto bool Insert(TKey key, TValue value)
Insert new element into map.
proto TValue Get(TKey key)
Search for an element with the given key.

Member Function Documentation

◆ Begin()

proto native MapIterator map< Class TKey, Class TValue >.Begin ( )

◆ Clear()

proto native void map< Class TKey, Class TValue >.Clear ( )

Clears the map.

◆ Contains()

proto bool map< Class TKey, Class TValue >.Contains ( TKey  key)

Returns whether map contains element with given key.

◆ Copy()

proto int map< Class TKey, Class TValue >.Copy ( map< TKey, TValue >  from)

◆ Count()

proto native int map< Class TKey, Class TValue >.Count ( )
Returns
Number of elements in the map.

◆ End()

proto native MapIterator map< Class TKey, Class TValue >.End ( )

◆ Find()

proto bool map< Class TKey, Class TValue >.Find ( TKey  key,
out TValue  val 
)

Search for an element with the given key.

Parameters
keyThe key of the element to find.
[out]valDestination where result will be stored.
Returns
true if given key exist.

◆ Get()

proto TValue map< Class TKey, Class TValue >.Get ( TKey  key)

Search for an element with the given key.

Parameters
keyThe key of the element to find.
Returns
value associated to given key or default for value type when key is not present

◆ GetElement()

proto TValue map< Class TKey, Class TValue >.GetElement ( int  index)

Return the i-th element in the map.

Note
This operation is O(n) complexity. Use with care!
Parameters
indexThe position of the element in the map.
Returns
The element on the i-th position.

◆ GetIteratorElement()

proto TValue map< Class TKey, Class TValue >.GetIteratorElement ( MapIterator  it)

◆ GetIteratorKey()

proto TKey map< Class TKey, Class TValue >.GetIteratorKey ( MapIterator  it)

◆ GetKey()

proto TKey map< Class TKey, Class TValue >.GetKey ( int  i)

Return the i-th element key in the map.

Note
This operation is O(n) complexity. Use with care!
Parameters
iThe position of the element key in the map.
Returns
Return key of i-th element.

◆ GetKeyByValue()

TKey map< Class TKey, Class TValue >.GetKeyByValue ( TValue  value)

◆ Insert()

proto bool map< Class TKey, Class TValue >.Insert ( TKey  key,
TValue  value 
)

Insert new element into map.

Parameters
keyKey of element to be inserted.
valueData of element to be inserted.

◆ IsEmpty()

proto native bool map< Class TKey, Class TValue >.IsEmpty ( )
Returns
true if the map size is 0, false otherwise.

◆ Next()

proto native MapIterator map< Class TKey, Class TValue >.Next ( MapIterator  it)

◆ Remove()

proto bool map< Class TKey, Class TValue >.Remove ( TKey  key)

◆ RemoveElement()

proto bool map< Class TKey, Class TValue >.RemoveElement ( int  i)

Removes i-th element with given key.

Note
This operation is O(n) complexity. Use with care!
Parameters
iThe position of the element key in the map.
Returns
true if element was removed.

◆ ReplaceKey()

bool map< Class TKey, Class TValue >.ReplaceKey ( TKey  old_key,
TKey  new_key 
)

◆ Set()

proto void map< Class TKey, Class TValue >.Set ( TKey  key,
TValue  value 
)

Sets value of element with given key.

If element with key does not exist, it is created.

Note
Creating new elements is faster using Insert() function.

◆ Take()

proto bool map< Class TKey, Class TValue >.Take ( TKey  key,
out TValue  value 
)

Search for an element with the given key and remove it.

Parameters
keyThe key of the element to find and remove.
[out]valDestination where result will be stored.
Returns
true if element was removed.

The documentation for this interface was generated from the following file: