Changeset 1158 for cpp/frams/vm/classes/collectionobj.cpp
- Timestamp:
- 10/01/21 23:40:49 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/vm/classes/collectionobj.cpp
r1130 r1158 31 31 { "size", 0, PARAM_READONLY | PARAM_NOSTATIC, "Element count", "d", GETONLY(size), }, 32 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)" },33 { "get", 0, PARAM_READONLY | 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 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 35 { "insert", 0, PARAM_NOSTATIC, "Insert value at position", "p(d position,x value)", PROCEDURE(p_insert), }, 36 36 { "add", 0, PARAM_NOSTATIC, "Append at the end", "p(x value)", PROCEDURE(p_add), }, 37 { "find", 0, PARAM_ NOSTATIC, "Find", "p d(x value)", PROCEDURE(p_find), "returns the element index or -1 if not found" },37 { "find", 0, PARAM_READONLY | PARAM_NOSTATIC, "Find", "p d(x value)", PROCEDURE(p_find), "returns the element index or -1 if not found" }, 38 38 { "avg", 0, PARAM_READONLY | PARAM_NOSTATIC, "Average", "x", GETONLY(avg) }, 39 39 { "stdev", 0, PARAM_READONLY | PARAM_NOSTATIC, "Standard deviation", "x", GETONLY(stdev), "=sqrt(sum((element[i]-avg)^2)/(size-1)) which is estimated population std.dev. from sample std.dev." }, … … 42 42 { "sort", 0, PARAM_NOSTATIC, "Sort elements (in place)", "p(oFunctionReference 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 from the 'function' operator.\n\nExample:\nfunction compareLastDigit(a,b) {return (a%10)<(b%10);}\nvar v=[16,23,35,42,54,61];\nv.sort(function compareLastDigit);" }, 43 43 { "iterator", 0, PARAM_NOSTATIC | PARAM_READONLY, "Iterator", "o", GETONLY(iterator), }, 44 { "clone", 0, PARAM_ NOSTATIC, "Create a clone", "p oVector()", PROCEDURE(p_clone), "The resulting clone is a shallow copy (contains the same object references as the original). A deep copy can be obtained through serialization: String.deserialize(String.serialize(object));" },44 { "clone", 0, PARAM_READONLY | PARAM_NOSTATIC, "Create a clone", "p oVector()", PROCEDURE(p_clone), "The resulting clone is a shallow copy (contains the same object references as the original). A deep copy can be obtained through serialization: String.deserialize(String.serialize(object));" }, 45 45 { 0, 0, 0, }, 46 46 }; … … 72 72 { "size", 0, PARAM_NOSTATIC | PARAM_READONLY, "Element count", "d", GETONLY(size), }, 73 73 { "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)." }, 74 { "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). Accessing nonexistent keys is an error (use hasKey() if necessary).\nobject.get(key) can be shortened to object[key]." },75 { "getKey", 0, PARAM_ NOSTATIC, "Get a key", "p s(d index)", PROCEDURE(p_getKey), "Returns the key of the indexed element (0 <= index < size)." },76 { "hasKey", 0, PARAM_ NOSTATIC, "Check if key exists", "p d(s key)", PROCEDURE(p_hasKey), "Returns 1 (interpreted as true) if dictionary contains the supplied key, or 0 (false) otherwise.\nExample:\n if (obj.hasKey(\"a\"))\n x = obj->a;" },74 { "get", 0, PARAM_READONLY | 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). Accessing nonexistent keys is an error (use hasKey() if necessary).\nobject.get(key) can be shortened to object[key]." }, 75 { "getKey", 0, PARAM_READONLY | PARAM_NOSTATIC, "Get a key", "p s(d index)", PROCEDURE(p_getKey), "Returns the key of the indexed element (0 <= index < size)." }, 76 { "hasKey", 0, PARAM_READONLY | PARAM_NOSTATIC, "Check if key exists", "p d(s key)", PROCEDURE(p_hasKey), "Returns 1 (interpreted as true) if dictionary contains the supplied key, or 0 (false) otherwise.\nExample:\n if (obj.hasKey(\"a\"))\n x = obj->a;" }, 77 77 { "set", 0, PARAM_NOSTATIC, "Set element", "p x(x key,x value)", PROCEDURE(p_set), "Set element value for the specified key or index (depending on the argument type: string or int).\n" 78 78 "Returns the value previously associated with the given key (or index).\n" … … 81 81 " var old_value=object.set(\"key\",new_value); //'old_value' gets the value previously associated with \"key\"\n" 82 82 " var x=object[\"key\"]=new_value; //'x' becomes 'new_value', consistently with the semantics of the assignment operator. The value previously associated with \"key\" is lost." }, 83 { "find", 0, PARAM_ NOSTATIC, "Find", "p x(x value)", PROCEDURE(p_find), "Returns the element key or null if not found." },83 { "find", 0, PARAM_READONLY | PARAM_NOSTATIC, "Find", "p x(x value)", PROCEDURE(p_find), "Returns the element key or null if not found." }, 84 84 { "new", 0, 0, "Create a Dictionary", "p oDictionary()", STATICPROCEDURE(p_new), "Empty directory can be also created using the {} expression." }, 85 85 { "toString", 0, PARAM_READONLY | PARAM_NOSTATIC, "Textual form", "s", GETONLY(toString), }, 86 { "clone", 0, PARAM_ NOSTATIC, "Create a clone", "p oDictionary()", PROCEDURE(p_clone), "The resulting clone is a shallow copy (contains the same object references as the original). A deep copy can be obtained through serialization: String.deserialize(String.serialize(object));" },86 { "clone", 0, PARAM_READONLY | PARAM_NOSTATIC, "Create a clone", "p oDictionary()", PROCEDURE(p_clone), "The resulting clone is a shallow copy (contains the same object references as the original). A deep copy can be obtained through serialization: String.deserialize(String.serialize(object));" }, 87 87 { "assign", 0, PARAM_NOSTATIC, "Assign from another object", "p(x)", PROCEDURE(p_assign), "Replaces current dictionary with dictionary contents from another object." }, 88 88 { "iterator", 0, PARAM_NOSTATIC | PARAM_READONLY, "Iterator", "o", GETONLY(iterator), }, … … 99 99 100 100 VectorObject::VectorObject(Pt3D &pt) 101 : readonly(0),owndata(1)101 :owndata(1) 102 102 { 103 103 set_or_insert(0, ExtValue(pt.x), false); … … 119 119 void VectorObject::p_remove(PARAMPROCARGS) 120 120 { 121 if (readonly) return;122 121 int i = args->getInt(); 123 122 if (!listIndexCheck(&data, i, "VectorObject", "remove")) return; … … 270 269 VMachine *vm; 271 270 VMVEComparator(VMachine::JumpTargetObject *_jto) :jto(_jto), vm(jto->vm) {} 272 #ifdef QSORT_R_ USING_QSORT_S271 #ifdef QSORT_R_THIS_FIRST 273 272 static int compare(void* _this, const void *a, const void *b); 274 273 bool operator()(const ExtValue *a, const ExtValue *b) { return compare(this,&a,&b) == ExtValue::ResultLower; } … … 279 278 }; 280 279 281 #ifdef QSORT_R_ USING_QSORT_S280 #ifdef QSORT_R_THIS_FIRST 282 281 int VMVEComparator::compare(void* _this, const void *a, const void *b) 283 282 #else … … 324 323 std::sort(first, first + data.size(), cmp); //no qsort_r() or equivalent on Android (yet) 325 324 #else 326 qsort_r(first, data.size(), sizeof(ExtValue*), cmp.compare, &cmp);325 CALL_QSORT_R(first, data.size(), sizeof(ExtValue*), cmp.compare, &cmp); 327 326 #endif 328 327 }
Note: See TracChangeset
for help on using the changeset viewer.