Enfusion Script API
Loading...
Searching...
No Matches
map Interface Template Reference

Associative array template. More...

Inheritance diagram for map:
Managed

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:485
proto TValue Get(TKey key)
Search for an element with the given key.
proto bool Insert(TKey key, TValue value)
Insert new element into map.

Member Function Documentation

◆ Begin()

proto native MapIterator map.Begin ( )

◆ Clear()

proto native void map.Clear ( )

Clears the map.

◆ Contains()

proto bool map.Contains ( TKey key)

Returns whether map contains element with given key.

◆ Copy()

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

◆ Count()

proto native int map.Count ( )
Returns
Number of elements in the map.

◆ End()

proto native MapIterator map.End ( )

◆ Find()

proto bool map.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.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.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.GetIteratorElement ( MapIterator it)

◆ GetIteratorKey()

proto TKey map.GetIteratorKey ( MapIterator it)

◆ GetKey()

proto TKey map.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.GetKeyByValue ( TValue value)

◆ Insert()

proto bool map.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.IsEmpty ( )
Returns
true if the map size is 0, false otherwise.

◆ Next()

proto native MapIterator map.Next ( MapIterator it)

◆ Remove()

proto bool map.Remove ( TKey key)

◆ RemoveElement()

proto bool map.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.ReplaceKey ( TKey old_key,
TKey new_key )

◆ Set()

proto void map.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.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]valueDestination where result will be stored.
Returns
true if element was removed.

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