Added Dictionary.values()

This commit is contained in:
J08nY 2016-06-05 14:20:52 +02:00
parent 56348cbbfe
commit dcce477f5e
No known key found for this signature in database
GPG Key ID: A7E1843A39B7D67A
4 changed files with 78 additions and 58 deletions

View File

@ -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 { const Variant* Dictionary::next(const Variant* p_key) const {
return _p->variant_map.next(p_key); return _p->variant_map.next(p_key);
@ -250,5 +262,3 @@ Dictionary::~Dictionary() {
_unref(); _unref();
} }

View File

@ -81,6 +81,7 @@ public:
const Variant* next(const Variant* p_key=NULL) const; const Variant* next(const Variant* p_key=NULL) const;
Array keys() const; Array keys() const;
Array values() const;
Dictionary(const Dictionary& p_from); Dictionary(const Dictionary& p_from);
Dictionary(bool p_shared=false); Dictionary(bool p_shared=false);

View File

@ -445,6 +445,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var
VCALL_LOCALMEM1(Dictionary,erase); VCALL_LOCALMEM1(Dictionary,erase);
VCALL_LOCALMEM0R(Dictionary,hash); VCALL_LOCALMEM0R(Dictionary,hash);
VCALL_LOCALMEM0R(Dictionary,keys); VCALL_LOCALMEM0R(Dictionary,keys);
VCALL_LOCALMEM0R(Dictionary,values);
VCALL_LOCALMEM1R(Dictionary,parse_json); VCALL_LOCALMEM1R(Dictionary,parse_json);
VCALL_LOCALMEM0R(Dictionary,to_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()); ADDFUNC1(DICTIONARY,NIL,Dictionary,erase,NIL,"value",varray());
ADDFUNC0(DICTIONARY,INT,Dictionary,hash,varray()); ADDFUNC0(DICTIONARY,INT,Dictionary,hash,varray());
ADDFUNC0(DICTIONARY,ARRAY,Dictionary,keys,varray()); ADDFUNC0(DICTIONARY,ARRAY,Dictionary,keys,varray());
ADDFUNC0(DICTIONARY,ARRAY,Dictionary,values,varray());
ADDFUNC1(DICTIONARY,INT,Dictionary,parse_json,STRING,"json",varray()); ADDFUNC1(DICTIONARY,INT,Dictionary,parse_json,STRING,"json",varray());
ADDFUNC0(DICTIONARY,STRING,Dictionary,to_json,varray()); ADDFUNC0(DICTIONARY,STRING,Dictionary,to_json,varray());

View File

@ -10312,7 +10312,7 @@ This approximation makes straight segments between each point, then subdivides t
<return type="Array"> <return type="Array">
</return> </return>
<description> <description>
Return the list of keys in the dictionary. Return the list of keys in the [Dictionary].
</description> </description>
</method> </method>
<method name="parse_json"> <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. Return the dictionary as json text.
</description> </description>
</method> </method>
<method name="values">
<return type="Array">
</return>
<description>
Return the list of values in the [Dictionary].
</description>
</method>
</methods> </methods>
<constants> <constants>
</constants> </constants>