30 #define RETAIN(element)
31 #define RELEASE(element)
33 #define RETAIN(element) VuoRetain((void *)element)
34 #define RELEASE(element) VuoRelease((void *)element)
36 #define RETAIN(element) VuoInteger_retain(element)
37 #define RELEASE(element) VuoInteger_release(element)
45 "title" :
"List of VuoInteger elements",
67 if (json_object_get_type(js) == json_type_array)
69 int itemCount = json_object_array_length(js);
70 for (
int i = 0; i < itemCount; ++i)
72 json_object *itemObject = json_object_array_get_idx(js, i);
86 for (
unsigned long i = 1; i <= itemCount; ++i)
90 json_object_array_add(listObject, itemObject);
96 #ifdef VuoInteger_REQUIRES_INTERPROCESS_JSON
102 for (
unsigned long i = 1; i <= itemCount; ++i)
105 json_object *itemObject = VuoInteger_getInterprocessJson(item);
106 json_object_array_add(listObject, itemObject);
116 return strdup(
"Empty list");
118 const int maxItems = 20;
119 const int maxCharacters = 400;
123 return strdup(
"Empty list");
125 unsigned long characterCount = 0;
127 std::ostringstream summary;
128 summary <<
"List containing " << itemCount <<
" item" << (itemCount == 1 ?
"" :
"s") <<
": <ul>";
130 for (i = 1; i <= itemCount && i <= maxItems && characterCount <= maxCharacters; ++i)
134 std::string itemSummary = itemSummaryCstr;
135 free(itemSummaryCstr);
136 if (itemSummary.length() && itemSummary.find_first_not_of(
' ') != std::string::npos)
137 summary <<
"<li>" << itemSummary <<
"</li>";
139 summary <<
"<li> </li>";
140 characterCount += itemSummary.length();
144 summary <<
"<li>…</li>";
148 return strdup(summary.str().c_str());
153 std::vector<VuoInteger> * l =
new std::vector<VuoInteger>;
155 return reinterpret_cast<VuoList_VuoInteger>(l);
160 std::vector<VuoInteger> * l =
new std::vector<VuoInteger>(count, value);
162 return reinterpret_cast<VuoList_VuoInteger>(l);
170 std::vector<VuoInteger> *oldList = (std::vector<VuoInteger> *)list;
172 std::vector<VuoInteger> *newList =
new std::vector<VuoInteger>(*oldList);
175 for (std::vector<VuoInteger>::iterator i = newList->begin(); i != newList->end(); ++i)
178 return reinterpret_cast<VuoList_VuoInteger>(newList);
190 std::vector<VuoInteger> * l = (std::vector<VuoInteger> *)list;
196 std::vector<VuoInteger> * l = (std::vector<VuoInteger> *)list;
198 if (!l || l->size() == 0)
204 if (index > l->size())
205 return (*l)[l->size()-1];
207 return (*l)[index-1];
212 std::vector<VuoInteger> * l = (std::vector<VuoInteger> *)list;
214 if (!l || l->size() == 0)
222 auto l =
reinterpret_cast<const std::vector<VuoInteger> *
>(list);
224 if (!l || l->size() == 0)
237 std::vector<VuoInteger> * l = (std::vector<VuoInteger> *)list;
239 if (!expandListIfNeeded && l->size() == 0)
242 unsigned long clampedIndex = index - 1;
247 if (expandListIfNeeded && clampedIndex >= l->size())
249 l->resize(clampedIndex + 1);
250 (*l)[clampedIndex] = value;
255 if (index > l->size())
256 clampedIndex = l->size() - 1;
261 (*l)[clampedIndex] = value;
272 std::vector<VuoInteger> * l = (std::vector<VuoInteger> *)list;
274 unsigned long clampedIndex = index - 1;
279 if (index > l->size())
280 clampedIndex = l->size() - 1;
283 if (index <= l->size())
284 l->insert(l->begin() + clampedIndex, value);
294 std::vector<VuoInteger> * l = (std::vector<VuoInteger> *)list;
296 l->insert(l->begin(), value);
304 std::vector<VuoInteger> * l = (std::vector<VuoInteger> *)list;
314 std::vector<VuoInteger> * l = (std::vector<VuoInteger> *)list;
316 size_t size = l->size();
320 unsigned long clampedIndexA = indexA - 1;
324 clampedIndexA = size - 1;
326 unsigned long clampedIndexB = indexB - 1;
330 clampedIndexB = size - 1;
333 (*l)[clampedIndexA] = (*l)[clampedIndexB];
334 (*l)[clampedIndexB] = value;
337 #ifdef VuoInteger_SUPPORTS_COMPARISON
343 std::vector<VuoInteger> * l = (std::vector<VuoInteger> *)list;
345 size_t size = l->size();
360 std::vector<VuoInteger> *a = (std::vector<VuoInteger> *)_a;
361 std::vector<VuoInteger> *b = (std::vector<VuoInteger> *)_b;
362 if (a->size() != b->size())
365 for (std::vector<VuoInteger>::iterator ia = a->begin(), ib = b->begin(); ia != a->end(); ++ia, ++ib)
377 std::vector<VuoInteger> *a = (std::vector<VuoInteger> *)_a;
378 std::vector<VuoInteger> *b = (std::vector<VuoInteger> *)_b;
379 if (a->size() < b->size())
return true;
380 if (a->size() > b->size())
return false;
382 for (std::vector<VuoInteger>::iterator ia = a->begin(), ib = b->begin(); ia != a->end(); ++ia, ++ib)
397 std::vector<VuoInteger> * l = (std::vector<VuoInteger> *)list;
399 size_t size = l->size();
403 double clampedChaos =
MIN(
MAX(chaos,0),1);
404 for (
unsigned long i = 0; i < size * clampedChaos; ++i)
418 std::vector<VuoInteger> * l = (std::vector<VuoInteger> *)list;
419 std::reverse(l->begin(), l->end());
427 std::vector<VuoInteger> * l = (std::vector<VuoInteger> *)list;
429 size_t size = l->size();
433 signed long clampedStartIndex = startIndex - 1;
434 signed long clampedEndIndex = clampedStartIndex + itemCount - 1;
436 if (clampedStartIndex < 0)
437 clampedStartIndex = 0;
438 if (clampedEndIndex >= (
signed long)size)
439 clampedEndIndex = size - 1;
441 if (clampedStartIndex > clampedEndIndex)
444 std::vector<VuoInteger> *newList =
new std::vector<VuoInteger>(
445 l->begin() + clampedStartIndex,
446 l->begin() + clampedEndIndex + 1);
449 for (std::vector<VuoInteger>::iterator i = newList->begin(); i != newList->end(); ++i)
452 return reinterpret_cast<VuoList_VuoInteger>(newList);
455 #ifdef VuoInteger_SUPPORTS_COMPARISON
461 auto *l = (std::vector<VuoInteger> *)list;
463 size_t size = l->size();
467 auto *newList =
new std::vector<VuoInteger>;
470 for (
auto i = l->begin(); i != l->end(); ++i)
473 for (
auto j = newList->begin(); j != newList->end(); ++j)
480 newList->push_back(*i);
483 for (
auto i = newList->begin(); i != newList->end(); ++i)
486 return reinterpret_cast<VuoList_VuoInteger>(newList);
495 std::vector<VuoInteger> * l = (std::vector<VuoInteger> *)list;
501 l->erase(l->begin());
509 std::vector<VuoInteger> * l = (std::vector<VuoInteger> *)list;
535 std::vector<VuoInteger> * l = (std::vector<VuoInteger> *)list;
537 size_t size = l->size();
538 if (size == 0 || index > size)
541 l->erase(l->begin() + index - 1);
549 std::vector<VuoInteger> * l = (std::vector<VuoInteger> *)list;