cocos2d-x  3.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Map< K, V > Class Template Reference

#include <CCMap.h>

Public Types

typedef std::unordered_map< K, V > RefMap
typedef RefMap::iterator iterator
typedef RefMap::const_iterator const_iterator

Public Member Functions

iterator begin ()
local begin ()
const_iterator begin () const
local begin ()
iterator end ()
var end ()
local end ()
const_iterator end () const
local end ()
const_iterator cbegin () const
local cbegin ()
const_iterator cend () const
local cend ()
 Map ()
 Default constructor. More...
 
 Map ()
 Default constructor. More...
 
 Map ()
 Default constructor. More...
 
 Map (ssize_t capacity)
 Contructor with capacity. More...
 
 Map ( var capacity)
 Contructor with capacity. More...
 
 Map ( local capacity)
 Contructor with capacity. More...
 
 Map (const Map< K, V > &other)
 Copy constructor. More...
 
 Map ( var K, var other)
 Copy constructor. More...
 
 Map ( local K, local other)
 Copy constructor. More...
 
 Map (Map< K, V > &&other)
 Move constructor. More...
 
 Map ( var K, var other)
 Move constructor. More...
 
 Map ( local K, local other)
 Move constructor. More...
 
 ~Map ()
 Destructor It will release all objects in map. More...
 
 ~Map ()
 Destructor It will release all objects in map. More...
 
 ~Map ()
 Destructor It will release all objects in map. More...
 
void reserve (ssize_t capacity)
 Sets capacity of the map. More...
 
var reserve ( var capacity)
 Sets capacity of the map. More...
 
local reserve ( local capacity)
 Sets capacity of the map. More...
 
ssize_t bucketCount () const
 Returns the number of buckets in the Map container. More...
 
var bucketCount ()
 Returns the number of buckets in the Map container. More...
 
local bucketCount ()
 Returns the number of buckets in the Map container. More...
 
ssize_t bucketSize (ssize_t n) const
 Returns the number of elements in bucket n. More...
 
ssize_t bucket (const K &k) const
 Returns the bucket number where the element with key k is located. More...
 
var bucket ( var k)
 Returns the bucket number where the element with key k is located. More...
 
local bucket ( local k)
 Returns the bucket number where the element with key k is located. More...
 
ssize_t size () const
 The number of elements in the map. More...
 
bool empty () const
 Returns a bool value indicating whether the map container is empty, i.e. More...
 
std::vector< K > keys () const
 Returns all keys in the map. More...
 
var keys ()
 Returns all keys in the map. More...
 
local keys ()
 Returns all keys in the map. More...
 
std::vector< K > keys (V object) const
 Returns all keys that matches the object. More...
 
local keys ( local object)
 Returns all keys that matches the object. More...
 
const V at (const K &key) const
 Returns a reference to the mapped value of the element with key k in the map. More...
 
at (const K &key)
const_iterator find (const K &key) const
 Searches the container for an element with 'key' as key and returns an iterator to it if found, otherwise it returns an iterator to Map<K, V>::end (the element past the end of the container). More...
 
local find ( local key)
 Searches the container for an element with 'key' as key and returns an iterator to it if found, otherwise it returns an iterator to Map<K, V>::end (the element past the end of the container). More...
 
iterator find (const K &key)
void insert (const K &key, V object)
 Inserts new elements in the map. More...
 
iterator erase (const_iterator position)
 Removes an element with an iterator from the Map<K, V> container. More...
 
local erase ( local position)
 Removes an element with an iterator from the Map<K, V> container. More...
 
size_t erase (const K &k)
 Removes an element with an iterator from the Map<K, V> container. More...
 
var erase ( var k)
 Removes an element with an iterator from the Map<K, V> container. More...
 
local erase ( local k)
 Removes an element with an iterator from the Map<K, V> container. More...
 
void erase (const std::vector< K > &keys)
 Removes some elements with a vector which contains keys in the map. More...
 
void clear ()
 All the elements in the Map<K,V> container are dropped: their reference count will be decreased, and they are removed from the container, leaving it with a size of 0. More...
 
getRandomObject () const
 Gets a random object in the map. More...
 
Map< K, V > & operator= (const Map< K, V > &other)
 Copy assignment operator. More...
 
local operator= ( local K, local other)
 Copy assignment operator. More...
 
Map< K, V > & operator= (Map< K, V > &&other)
 Move assignment operator. More...
 
var operator= ( var K, var other)
 Move assignment operator. More...
 
local operator= ( local K, local other)
 Move assignment operator. More...
 

Protected Member Functions

void addRefForAllObjects ()
 Retains all the objects in the map. More...
 
var addRefForAllObjects ()
 Retains all the objects in the map. More...
 
local addRefForAllObjects ()
 Retains all the objects in the map. More...
 

Protected Attributes

RefMap _data
var _data
local _data

Member Typedef Documentation

typedef RefMap::const_iterator
const_iterator
typedef RefMap::iterator iterator
var iterator
local iterator
typedef std::unordered_map<K,
V> RefMap
var RefMap
local RefMap

Constructor & Destructor Documentation

Map ( )
inline

Default constructor.

var Map ( )
inline

Default constructor.

local Map ( )
inline

Default constructor.

Map ( ssize_t  capacity)
inlineexplicit

Contructor with capacity.

var Map ( var  capacity)
inlineexplicit

Contructor with capacity.

local Map ( local  capacity)
inlineexplicit

Contructor with capacity.

Map ( const Map< K, V > &  other)
inline

Copy constructor.

var Map ( var  other)
inline

Copy constructor.

local Map ( local  other)
inline

Copy constructor.

Map ( Map< K, V > &&  other)
inline

Move constructor.

var Map ( var  other)
inline

Move constructor.

local Map ( local  other)
inline

Move constructor.

~Map ( )
inline

Destructor It will release all objects in map.

var ~Map ( )
inline

Destructor It will release all objects in map.

local ~Map ( )
inline

Destructor It will release all objects in map.

Member Function Documentation

void addRefForAllObjects ( )
inlineprotected

Retains all the objects in the map.

var addRefForAllObjects ( )
inlineprotected

Retains all the objects in the map.

local addRefForAllObjects ( )
inlineprotected

Retains all the objects in the map.

const V at ( const K &  key) const
inline

Returns a reference to the mapped value of the element with key k in the map.

Note
If key does not match the key of any element in the container, the function return nullptr.
Parameters
keyKey value of the element whose mapped value is accessed. Member type K is the keys for the elements in the container. defined in Map<K, V> as an alias of its first template parameter (Key).
var at ( var  key)
inline

Returns a reference to the mapped value of the element with key k in the map.

Note
If key does not match the key of any element in the container, the function return nullptr.
Parameters
keyKey value of the element whose mapped value is accessed. Member type K is the keys for the elements in the container. defined in Map<K, V> as an alias of its first template parameter (Key).
local at ( local  key)
inline

Returns a reference to the mapped value of the element with key k in the map.

Note
If key does not match the key of any element in the container, the function return nullptr.
Parameters
keyKey value of the element whose mapped value is accessed. Member type K is the keys for the elements in the container. defined in Map<K, V> as an alias of its first template parameter (Key).
V at ( const K &  key)
inline
var at ( var  key)
inline
local at ( local  key)
inline
iterator begin ( )
inline
var begin ( )
inline
local begin ( )
inline
const_iterator begin ( ) const
inline
var begin ( )
inline
local begin ( )
inline
ssize_t bucket ( const K &  k) const
inline

Returns the bucket number where the element with key k is located.

var bucket ( var  k)
inline

Returns the bucket number where the element with key k is located.

local bucket ( local  k)
inline

Returns the bucket number where the element with key k is located.

ssize_t bucketCount ( ) const
inline

Returns the number of buckets in the Map container.

var bucketCount ( )
inline

Returns the number of buckets in the Map container.

local bucketCount ( )
inline

Returns the number of buckets in the Map container.

ssize_t bucketSize ( ssize_t  n) const
inline

Returns the number of elements in bucket n.

var bucketSize ( var  n)
inline

Returns the number of elements in bucket n.

local bucketSize ( local  n)
inline

Returns the number of elements in bucket n.

const_iterator cbegin ( ) const
inline
var cbegin ( )
inline
local cbegin ( )
inline
const_iterator cend ( ) const
inline
var cend ( )
inline
local cend ( )
inline
void clear ( )
inline

All the elements in the Map<K,V> container are dropped: their reference count will be decreased, and they are removed from the container, leaving it with a size of 0.

var clear ( )
inline

All the elements in the Map<K,V> container are dropped: their reference count will be decreased, and they are removed from the container, leaving it with a size of 0.

local clear ( )
inline

All the elements in the Map<K,V> container are dropped: their reference count will be decreased, and they are removed from the container, leaving it with a size of 0.

bool empty ( ) const
inline

Returns a bool value indicating whether the map container is empty, i.e.

whether its size is 0.

Note
This function does not modify the content of the container in any way. To clear the content of an array object, member function unordered_map::clear exists.
var empty ( )
inline

Returns a bool value indicating whether the map container is empty, i.e.

whether its size is 0.

Note
This function does not modify the content of the container in any way. To clear the content of an array object, member function unordered_map::clear exists.
local empty ( )
inline

Returns a bool value indicating whether the map container is empty, i.e.

whether its size is 0.

Note
This function does not modify the content of the container in any way. To clear the content of an array object, member function unordered_map::clear exists.
iterator end ( )
inline
var end ( )
inline
local end ( )
inline
const_iterator end ( ) const
inline
var end ( )
inline
local end ( )
inline
iterator erase ( const_iterator  position)
inline

Removes an element with an iterator from the Map<K, V> container.

Parameters
positionIterator pointing to a single element to be removed from the Map<K, V>. Member type const_iterator is a forward iterator type.
var erase ( var  position)
inline

Removes an element with an iterator from the Map<K, V> container.

Parameters
positionIterator pointing to a single element to be removed from the Map<K, V>. Member type const_iterator is a forward iterator type.
local erase ( local  position)
inline

Removes an element with an iterator from the Map<K, V> container.

Parameters
positionIterator pointing to a single element to be removed from the Map<K, V>. Member type const_iterator is a forward iterator type.
size_t erase ( const K &  k)
inline

Removes an element with an iterator from the Map<K, V> container.

Parameters
kKey of the element to be erased. Member type 'K' is the type of the keys for the elements in the container, defined in Map<K, V> as an alias of its first template parameter (Key).
var erase ( var  k)
inline

Removes an element with an iterator from the Map<K, V> container.

Parameters
kKey of the element to be erased. Member type 'K' is the type of the keys for the elements in the container, defined in Map<K, V> as an alias of its first template parameter (Key).
local erase ( local  k)
inline

Removes an element with an iterator from the Map<K, V> container.

Parameters
kKey of the element to be erased. Member type 'K' is the type of the keys for the elements in the container, defined in Map<K, V> as an alias of its first template parameter (Key).
void erase ( const std::vector< K > &  keys)
inline

Removes some elements with a vector which contains keys in the map.

Parameters
keysKeys of elements to be erased.
var erase ( var  keys)
inline

Removes some elements with a vector which contains keys in the map.

Parameters
keysKeys of elements to be erased.
local erase ( local  keys)
inline

Removes some elements with a vector which contains keys in the map.

Parameters
keysKeys of elements to be erased.
const_iterator find ( const K &  key) const
inline

Searches the container for an element with 'key' as key and returns an iterator to it if found, otherwise it returns an iterator to Map<K, V>::end (the element past the end of the container).

Parameters
keyKey to be searched for. Member type 'K' is the type of the keys for the elements in the container, defined in Map<K, V> as an alias of its first template parameter (Key).
var find ( var  key)
inline

Searches the container for an element with 'key' as key and returns an iterator to it if found, otherwise it returns an iterator to Map<K, V>::end (the element past the end of the container).

Parameters
keyKey to be searched for. Member type 'K' is the type of the keys for the elements in the container, defined in Map<K, V> as an alias of its first template parameter (Key).
local find ( local  key)
inline

Searches the container for an element with 'key' as key and returns an iterator to it if found, otherwise it returns an iterator to Map<K, V>::end (the element past the end of the container).

Parameters
keyKey to be searched for. Member type 'K' is the type of the keys for the elements in the container, defined in Map<K, V> as an alias of its first template parameter (Key).
iterator find ( const K &  key)
inline
var find ( var  key)
inline
local find ( local  key)
inline
V getRandomObject ( ) const
inline

Gets a random object in the map.

Returns
Returns the random object if the map isn't empty, otherwise it returns nullptr.
var getRandomObject ( )
inline

Gets a random object in the map.

Returns
Returns the random object if the map isn't empty, otherwise it returns nullptr.
local getRandomObject ( )
inline

Gets a random object in the map.

Returns
Returns the random object if the map isn't empty, otherwise it returns nullptr.
void insert ( const K &  key,
object 
)
inline

Inserts new elements in the map.

Note
If the container has already contained the key, this function will erase the old pair(key, object) and insert the new pair.
Parameters
keyThe key to be inserted.
objectThe object to be inserted.
var insert ( var  key,
var  object 
)
inline

Inserts new elements in the map.

Note
If the container has already contained the key, this function will erase the old pair(key, object) and insert the new pair.
Parameters
keyThe key to be inserted.
objectThe object to be inserted.
local insert ( local  key,
local  object 
)
inline

Inserts new elements in the map.

Note
If the container has already contained the key, this function will erase the old pair(key, object) and insert the new pair.
Parameters
keyThe key to be inserted.
objectThe object to be inserted.
std::vector<K> keys ( ) const
inline

Returns all keys in the map.

var keys ( )
inline

Returns all keys in the map.

local keys ( )
inline

Returns all keys in the map.

std::vector<K> keys ( object) const
inline

Returns all keys that matches the object.

var keys ( var  object)
inline

Returns all keys that matches the object.

local keys ( local  object)
inline

Returns all keys that matches the object.

Map<K, V>& operator= ( const Map< K, V > &  other)
inline

Copy assignment operator.

Map<K, V>& operator= ( var  other)
inline

Copy assignment operator.

Map<K, V>& operator= ( local  other)
inline

Copy assignment operator.

Map<K, V>& operator= ( Map< K, V > &&  other)
inline

Move assignment operator.

Map<K, V>& operator= ( var  other)
inline

Move assignment operator.

Map<K, V>& operator= ( local  other)
inline

Move assignment operator.

void reserve ( ssize_t  capacity)
inline

Sets capacity of the map.

var reserve ( var  capacity)
inline

Sets capacity of the map.

local reserve ( local  capacity)
inline

Sets capacity of the map.

ssize_t size ( ) const
inline

The number of elements in the map.

var size ( )
inline

The number of elements in the map.

local size ( )
inline

The number of elements in the map.

Member Data Documentation

RefMap _data
protected
var _data
protected
local _data
protected

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