Merge pull request #5048 from J08nY/dictionary
Added Dictionary.values()
This commit is contained in:
commit
7499fa4507
4 changed files with 78 additions and 58 deletions
|
@ -199,6 +199,18 @@ Array Dictionary::keys() const {
|
|||
|
||||
}
|
||||
|
||||
Array Dictionary::values() const {
|
||||
|
||||
Array varr;
|
||||
varr.resize(size());
|
||||
const Variant *key=NULL;
|
||||
int i=0;
|
||||
while((key=next(key))){
|
||||
varr[i++] = _p->variant_map[*key];
|
||||
}
|
||||
return varr;
|
||||
}
|
||||
|
||||
const Variant* Dictionary::next(const Variant* p_key) const {
|
||||
|
||||
return _p->variant_map.next(p_key);
|
||||
|
@ -250,5 +262,3 @@ Dictionary::~Dictionary() {
|
|||
|
||||
_unref();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -81,6 +81,7 @@ public:
|
|||
const Variant* next(const Variant* p_key=NULL) const;
|
||||
|
||||
Array keys() const;
|
||||
Array values() const;
|
||||
|
||||
Dictionary(const Dictionary& p_from);
|
||||
Dictionary(bool p_shared=false);
|
||||
|
|
|
@ -445,6 +445,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var
|
|||
VCALL_LOCALMEM1(Dictionary,erase);
|
||||
VCALL_LOCALMEM0R(Dictionary,hash);
|
||||
VCALL_LOCALMEM0R(Dictionary,keys);
|
||||
VCALL_LOCALMEM0R(Dictionary,values);
|
||||
VCALL_LOCALMEM1R(Dictionary,parse_json);
|
||||
VCALL_LOCALMEM0R(Dictionary,to_json);
|
||||
|
||||
|
@ -1434,6 +1435,7 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl
|
|||
ADDFUNC1(DICTIONARY,NIL,Dictionary,erase,NIL,"value",varray());
|
||||
ADDFUNC0(DICTIONARY,INT,Dictionary,hash,varray());
|
||||
ADDFUNC0(DICTIONARY,ARRAY,Dictionary,keys,varray());
|
||||
ADDFUNC0(DICTIONARY,ARRAY,Dictionary,values,varray());
|
||||
|
||||
ADDFUNC1(DICTIONARY,INT,Dictionary,parse_json,STRING,"json",varray());
|
||||
ADDFUNC0(DICTIONARY,STRING,Dictionary,to_json,varray());
|
||||
|
|
|
@ -10312,7 +10312,7 @@ This approximation makes straight segments between each point, then subdivides t
|
|||
<return type="Array">
|
||||
</return>
|
||||
<description>
|
||||
Return the list of keys in the dictionary.
|
||||
Return the list of keys in the [Dictionary].
|
||||
</description>
|
||||
</method>
|
||||
<method name="parse_json">
|
||||
|
@ -10338,6 +10338,13 @@ This approximation makes straight segments between each point, then subdivides t
|
|||
Return the dictionary as json text.
|
||||
</description>
|
||||
</method>
|
||||
<method name="values">
|
||||
<return type="Array">
|
||||
</return>
|
||||
<description>
|
||||
Return the list of values in the [Dictionary].
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
<constants>
|
||||
</constants>
|
||||
|
|
Loading…
Reference in a new issue