 Timestamp:
 07/02/15 11:06:03 (9 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

cpp/frams/vm/classes/collectionobj.cpp
r392 r409 17 17 {"Vector",1,13,"Vector","Vector is a 1dimensional array indexed by an integer value (starting from 0). " 18 18 "Multidimensional arrays can be simulated by putting other Vector objects into a Vector.\n" 19 "Examples:\n" 20 "var v1=Vector.new(); v1.add(123); v1.add(\"string\");\n" 21 "var v2=[123,\"string\"]; //a short way of doing the same (square brackets create a vector)\n" 22 "var v3=[[1,2,3],[4,5],[6]]; //simulate a 2D array\n" 23 "for(var element in v3) Simulator.print(element); //Vector supports enumeration" 19 "Examples:\n" 20 "\tvar v1=Vector.new();\n" 21 "\tv1.add(123);\n" 22 "\tv1.add(\"string\");\n" 23 "A short way of doing the same (square brackets create a vector):\n" 24 "\tvar v2=[123,\"string\"];\n" 25 "Simulate a 2D array:\n" 26 "\tvar v3=[[1,2,3],[4,5],[6]];\n" 27 "You can iterate directly over values of a Vector using for(...in...) loops:\n" 28 "\tfor(var element in v3) Simulator.print(element);" 24 29 }, 25 {"clear",0,PARAM_NOSTATIC," clear data","p()",PROCEDURE(p_clear),},26 {"size",0,PARAM_READONLY  PARAM_NOSTATIC," element count","d",GETONLY(size),},27 {"remove",0,PARAM_NOSTATIC," remove at position","p(d position)",PROCEDURE(p_remove),},28 {"get",0,PARAM_NOSTATIC," get value at position","p x(d position)",PROCEDURE(p_get),"object[position] can be always used instead of object.get(position)"},29 {"set",0,PARAM_NOSTATIC," set value at position","p(d position,x value)",PROCEDURE(p_set),"object[position]=value can be always used instead of object.set(position,value)"},30 {"add",0,PARAM_NOSTATIC," append at the end","p(x value)",PROCEDURE(p_add),},31 {"find",0,PARAM_NOSTATIC," find","p d(x value)",PROCEDURE(p_find),"returns the element index or 1 if not found"},32 {"avg",0,PARAM_READONLY  PARAM_NOSTATIC," average","f",GETONLY(avg)},33 {"stdev",0,PARAM_READONLY  PARAM_NOSTATIC," standard deviation","f",GETONLY(stdev),"=sqrt(sum((element[i]avg)^2)/(size1)) which is estimated population std.dev. from sample std.dev."},34 {"toString",0,PARAM_READONLY  PARAM_NOSTATIC," textual form","s",GETONLY(toString),},35 {"new",0,0," create new Vector","p oVector()",STATICPROCEDURE(p_new),},36 {"sort",0,PARAM_NOSTATIC," sort elements (in place)","p(o comparator)",PROCEDURE(p_sort),"comparator can be null, giving the \"natural\" sorting order (depending on element type), otherwise it must be a function reference obtained by the \"function FUNCTIONNAME\" operator.\n\nExample:\nfunction compareLastDigit(a,b) {return (a%10)<(b%10);}\nvar v=[16,23,35,42,54,61];\nv.sort(function compareLastDigit);"},37 {"iterator",0,PARAM_NOSTATIC  PARAM_READONLY," iterator","o",GETONLY(iterator),},30 {"clear",0,PARAM_NOSTATIC,"Clear data","p()",PROCEDURE(p_clear),}, 31 {"size",0,PARAM_READONLY  PARAM_NOSTATIC,"Element count","d",GETONLY(size),}, 32 {"remove",0,PARAM_NOSTATIC,"Remove at position","p(d position)",PROCEDURE(p_remove),}, 33 {"get",0,PARAM_NOSTATIC,"Get value at position","p x(d position)",PROCEDURE(p_get),"object[position] can be always used instead of object.get(position)"}, 34 {"set",0,PARAM_NOSTATIC,"Set value at position","p(d position,x value)",PROCEDURE(p_set),"object[position]=value can be always used instead of object.set(position,value)"}, 35 {"add",0,PARAM_NOSTATIC,"Append at the end","p(x value)",PROCEDURE(p_add),}, 36 {"find",0,PARAM_NOSTATIC,"Find","p d(x value)",PROCEDURE(p_find),"returns the element index or 1 if not found"}, 37 {"avg",0,PARAM_READONLY  PARAM_NOSTATIC,"Average","f",GETONLY(avg)}, 38 {"stdev",0,PARAM_READONLY  PARAM_NOSTATIC,"Standard deviation","f",GETONLY(stdev),"=sqrt(sum((element[i]avg)^2)/(size1)) which is estimated population std.dev. from sample std.dev."}, 39 {"toString",0,PARAM_READONLY  PARAM_NOSTATIC,"Textual form","s",GETONLY(toString),}, 40 {"new",0,0,"Create new Vector","p oVector()",STATICPROCEDURE(p_new),}, 41 {"sort",0,PARAM_NOSTATIC,"Sort elements (in place)","p(o comparator)",PROCEDURE(p_sort),"comparator can be null, giving the \"natural\" sorting order (depending on element type), otherwise it must be a function reference obtained by the \"function FUNCTIONNAME\" operator.\n\nExample:\nfunction compareLastDigit(a,b) {return (a%10)<(b%10);}\nvar v=[16,23,35,42,54,61];\nv.sort(function compareLastDigit);"}, 42 {"iterator",0,PARAM_NOSTATIC  PARAM_READONLY,"Iterator","o",GETONLY(iterator),}, 38 43 {0,0,0,}, 39 44 }; … … 44 49 { 45 50 {"Dictionary",1,9,"Dictionary","Dictionary associates stored values with string keys " 46 "(\"key\" is the first argument in get/set/remove functions). Integer \"key\"can be "51 "(\"key\" is the first argument in get/set/remove functions). Integer key can be " 47 52 "used to enumerate all elements (note that while iterating, the elements are returned in no particular order).\n" 48 "Examples:\nvar d1=Dictionary.new(); d1.set(\"name\",\"John\"); d1.set(\"age\",44);\n" 49 "var d2=Dictionary.new(); d2[\"name\"]=\"John\"; d2[\"age\"]=44; //shorthand notation equivalent to the line above\n" 50 "var i;\nfor(i=0;i<d.size;i++) Simulator.print(d.getKey(i)+\" is \"+d.get(i));",}, 51 {"clear",0,PARAM_NOSTATIC,"clear data","p()",PROCEDURE(p_clear),}, 52 {"size",0,PARAM_NOSTATIC  PARAM_READONLY,"element count","d",GETONLY(size),}, 53 {"remove",0,PARAM_NOSTATIC,"remove named or indexed element","p(x key)",PROCEDURE(p_remove),}, 54 {"get",0,PARAM_NOSTATIC,"get named or indexed element","p x(x key)",PROCEDURE(p_get),"object[position] can be always used instead of object.get(position)"}, 55 {"getKey",0,PARAM_NOSTATIC,"get a key of the indexed element","p s(d index)",PROCEDURE(p_getKey),}, 56 {"set",0,PARAM_NOSTATIC,"set named or indexed element","p(x key,x value)",PROCEDURE(p_set),"object[key]=value can be always used instead of object.set(key,value)"}, 57 {"find",0,PARAM_NOSTATIC,"find","p s(x value)",PROCEDURE(p_find),"returns the element key or null if not found"}, 58 {"new",0,0,"create new Dictionary","p oDictionary()",STATICPROCEDURE(p_new),}, 59 {"toString",0,PARAM_READONLY  PARAM_NOSTATIC,"textual form","s",GETONLY(toString),}, 53 "Examples:\n" 54 "\tvar d;\n" 55 "\td=Dictionary.new();\n" 56 "\td.set(\"name\",\"John\");\n" 57 "\td.set(\"age\",44);\n" 58 "Another way of doing the same:\n" 59 "\td={};\n" 60 "\td[\"name\"]=\"John\";\n" 61 "\td[\"age\"]=44;\n" 62 "And the most concise way:\n" 63 "\td={ \"name\":\"John\", \"age\":44 };\n" 64 "Iterating:\n" 65 "\tfor(var i=0;i<d.size;i++) Simulator.print(d.getKey(i)+\" is \"+d.get(i));", 66 }, 67 {"clear",0,PARAM_NOSTATIC,"Clear data","p()",PROCEDURE(p_clear),}, 68 {"size",0,PARAM_NOSTATIC  PARAM_READONLY,"Element count","d",GETONLY(size),}, 69 {"remove",0,PARAM_NOSTATIC,"Remove","p(x key)",PROCEDURE(p_remove),"Removes the named or indexed element (depending on the argument type: string or int)."}, 70 {"get",0,PARAM_NOSTATIC,"Get element","p x(x key)",PROCEDURE(p_get),"Retrieves the named or indexed element (depending on the argument type: string or int). null is returned for nonexistent keys.\nobject.get(key) can be shortened to 'object[key]'"}, 71 {"getKey",0,PARAM_NOSTATIC,"Get a key","p s(d index)",PROCEDURE(p_getKey),"Returns the key of the indexed element (0 <= index < size)"}, 72 {"set",0,PARAM_NOSTATIC,"Set element","p(x key,x value)",PROCEDURE(p_set),"Set element value for the specified key or index (depending on the argument type: string or int).\nobject.set(key,value) can be shortened to object[key]=value"}, 73 {"find",0,PARAM_NOSTATIC,"Find","p x(x value)",PROCEDURE(p_find),"Returns the element key or null if not found."}, 74 {"new",0,0,"Create a Dictionary","p oDictionary()",STATICPROCEDURE(p_new),"Empty directory can be also created using the {} expression."}, 75 {"toString",0,PARAM_READONLY  PARAM_NOSTATIC,"Textual form","s",GETONLY(toString),}, 60 76 {0,0,0,}, 61 77 };
Note: See TracChangeset
for help on using the changeset viewer.