5#include "integer_map.h"
16 template<prototype_array ARRAY1, prototype_array ARRAY2>
17 bool is_equal(
const ARRAY1 & array1,
const ARRAY2 & array2)
20 if (array1.get_size() != array2.get_size())
27 for (::collection::index i = 0; i < array1.get_size(); i++)
30 if (array1.element_at(i) != array2.element_at(i))
44 template<prototype_array ARRAY1, prototype_array ARRAY2>
45 bool is_different(
const ARRAY1 & array1,
const ARRAY2 & array2)
48 return !is_equal(array1, array2);
68#include "acme/prototype/prototype/compare_predicate.h"
73template <
class TYPE,
class ARG_TYPE = const TYPE &,
class TYPED = ::typed::nodef < TYPE >,
class MEMORY = ::heap::typed_memory < TYPE, ::heap::e_memory_array >, ::enum_type t_etypeContainer = e_type_element >
74inline auto& __array_object(::base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >& a, ::collection::index i);
77template <
typename ARRAY_TYPE,
typename T >
78inline auto& __array_object(::pointer_array_process < ARRAY_TYPE, T >& a, ::collection::index i);
85 template <
class TDST,
class TSRC >
86 ::collection::count copy(pointer_array < TDST >& dsta,
const pointer_array < TSRC >& srca);
89 template <
class A,
class T >
104 template <
class TDST,
class TSRC >
105 ::collection::count copy(address_array_base < TDST >& dsta,
const address_array_base < TSRC >& srca);
107 template <
class TDST,
class TSRC >
108 ::collection::count ptrcopy(TDST& dsta,
const TSRC& srca);
118 template <
class TDST,
class TSRC >
119 ::collection::count copy(TDST& dsta,
const TSRC& srca);
121 template <
typename CONTAINER,
class TYPE >
122 bool contains_item(
const CONTAINER& container,
const TYPE& t);
162 template <
class TINTERSECTION,
class TDST,
class TSRC >
163 void intersection(TINTERSECTION& intersection,
const TDST& dsta,
const TSRC& srca);
171 while (a.get_count() > 0)
174 ::collection::index i = (::collection::index)(rand() % a.get_size());
175 b.add(a.element_at(i));
186 typename A::BASE_TYPE pick_random(A& a)
189 ::collection::index i = (::collection::index)(rand() % a.get_size());
191 return a.element_at(i);
197 typename A::BASE_TYPE pop_random(A& a)
200 ::collection::index i = (::collection::index)(rand() % a.get_size());
202 auto matter = a.element_at(i);
211 template <
class A,
class TYPE >
212 ::collection::count populate(A& a, TYPE start, TYPE end, TYPE step,
bool bIncludeStart =
true,
bool bIncludeEnd =
true,
bool bIncludeEndOnStep =
true)
215 ::collection::count count = 0;
328 if (bIncludeEndOnStep)
367 template <
typename ARRAY >
368 ::collection::index find_first(
const ARRAY& a,
typename ARRAY::BASE_ARG_TYPE t, ::collection::index(*pfnCompare)(
typename ARRAY::BASE_ARG_TYPE,
typename ARRAY::BASE_ARG_TYPE), ::collection::index find = 0, ::collection::index last = -1)
374 find += a.get_count();
381 last += a.get_count();
385 for (; find <= last; find++)
388 if (pfnCompare((
typename ARRAY::BASE_ARG_TYPE)a.element_at(find), (
typename ARRAY::BASE_ARG_TYPE)t) == 0)
408 template <
typename A >
409 bool ci_is(
const A& a,
const typename A::BASE_TYPE& t)
415 if (::case_insensitive_ansi_compare(i, t))
428 template <
typename A >
457 void array_merge(A& a,
const A& a1,
const A& a2)
463 void array_makecombination(pointer_array < A >& comb,
const A& a, A blindprefixa = A(), ::collection::index idx = 0)
465 comb.
add(allocateø A(blindprefixa));
466 for (::collection::index i = idx; i < a.get_count(); i++)
468 array_makecombination(comb, a, blindprefixa + make_array < A >(a[i]), i + 1);
486 template <
class A,
class A2D >
487 void array_permute(A2D& perm,
const A& a);
490 void array_permute(pointer_array < A >& perm,
const A& a);
492 CLASS_DECL_ACME string_array_base x1_decode_ida(const ::scoped_string & scopedstr);
494 CLASS_DECL_ACME
string x1_encode_ida(
const string_array_base& stra);
498 void x1_on_erase(
const A& a,
typename A::BASE_TYPE& n)
500 ::collection::count c = 0;
501 for (::collection::index i = 0; i < a.get_size(); i++)
525 template <
typename Type,
typename RawType, ::enum_type t_etypeContainer >
526 ::collection::index add(string_base_array < Type, RawType, t_etypeContainer >& array,
const Type& psz)
529 auto iIndex = __index(array.m_nSize);
531 array.set_at_grow(iIndex, psz);
538 template <
typename Type,
typename RawType, ::enum_type t_etypeContainer >
539 ::collection::index add(string_base_array < Type, RawType, t_etypeContainer >& array, const ::payload& payload);
542 template <
typename Type,
typename RawType, ::enum_type t_etypeContainer >
543 ::collection::index unfold_add(string_base_array < Type, RawType, t_etypeContainer >& array, const ::payload& payload);
545 template <
typename TYPE, ::enum_type t_etypeContainer = e_type_element >
546 ::collection::count ensure_sequence(::numeric_array_base < TYPE, t_etypeContainer >& a, TYPE start, TYPE end, TYPE increment = 1);
548 template <
typename TYPE, ::enum_type t_etypeContainer = e_type_element >
549 ::collection::count append_sequence(::numeric_array_base < TYPE, t_etypeContainer >& a, TYPE iterator, TYPE end, TYPE increment = 1);
551 template <
typename TYPE, ::enum_type t_etypeContainer = e_type_element >
552 ::collection::count set_sequence(::numeric_array_base < TYPE, t_etypeContainer >& a, TYPE start, TYPE end, TYPE increment = 1);
554 template<
class ARRAY>
555 bool binary_search(ARRAY& a,
typename ARRAY::BASE_ARG_TYPE t, ::collection::index& iIndex, ::collection::index(*fCompare) (
typename ARRAY::BASE_ARG_TYPE,
typename ARRAY::BASE_ARG_TYPE));
557 template<
class ARRAY>
558 bool binary_search(ARRAY& a,
typename ARRAY::BASE_ARG_TYPE t, ::collection::index& iIndex, less_predicate_base < typename ARRAY::BASE_ARG_TYPE >* pcompare, index_array& ia);
560 template<
class ARRAY>
561 ::collection::index sort_add(ARRAY& a,
typename ARRAY::BASE_ARG_TYPE t, ::collection::index(*fCompare) (
typename ARRAY::BASE_ARG_TYPE,
typename ARRAY::BASE_ARG_TYPE), index_array& ia);
563 template<
class ARRAY,
class ARRAY2>
564 ::collection::count sort_add_array(ARRAY& a, ARRAY2& a2, ::collection::index(*fCompare) (
typename ARRAY::BASE_ARG_TYPE,
typename ARRAY::BASE_ARG_TYPE), index_array& ia);
566 template<
class ARRAY>
567 inline typename ARRAY::BASE_TYPE pop(ARRAY& a, ::collection::index n = -1);
569 template<
class ARRAY>
570 inline void pop_back(ARRAY& a, ::collection::index n = -1);
572 template<
class ARRAY>
573 inline ::collection::index push(ARRAY& a,
typename ARRAY::BASE_ARG_TYPE newElement, ::collection::index n = 0);
575 template<
class ARRAY>
576 inline void add(ARRAY& a,
typename ARRAY::BASE_ARG_TYPE newElement, ::collection::index n = 0);
578 template<
class TARGET,
class SOURCE> inline ::collection::index add(TARGET& target,
const SOURCE& source)
581 return target.add(source);
586 template <
typename ARRAY1,
typename ARRAY2>
587 inline ::collection::index add_array(ARRAY1& array1,
const ARRAY2& array2)
590 ::collection::index i = -1;
592 for (
auto& item : array2)
595 ::collection::index iItem = array1.add_item(item);
611 template <
typename ARRAY1,
typename ARRAY2>
612 inline ::collection::index unfold_array(ARRAY1& array1,
const ARRAY2& array2)
615 ::collection::index i = -1;
617 for (
auto& item : array2)
620 ::collection::index iItem = add(array1, item);
636 inline ::collection::index add(string_array_base& stra, const ::scoped_string & scopedstr);
637 inline ::collection::index add(string_array_base& stra, const ::i8& ch);
638 inline ::collection::index add(string_array_base& stra,
const ansi_string& str);
639 inline ::collection::index add(string_array_base& stra,
const wide_string& str);
640 inline ::collection::index add(string_array_base& stra, const ::file::path& path);
641 inline ::collection::index add(string_array_base& stra, const ::payload& payload);
642 inline ::collection::index add(string_array_base& stra, const ::property& property);
643 inline ::collection::index add(string_array_base& stra, const ::property_set& propertyset);
645 inline ::collection::index add(::file::path_array_base& patha, const ::scoped_string & scopedstr);
647 inline ::collection::index add(string_array_base& stra,
const string_array_base& straSource);
649 inline ::collection::index add(::file::path_array_base& patha,
const string_array_base& stra);
650 inline ::collection::index add(::file::path_array_base& patha, const ::file::path_array_base& pathaSrc);
651 inline ::collection::index add(::file::path_array_base& patha, const ::file::listing_base& listing);
653 template <
typename T >
654 inline bool are_all_elements_equal(
const pointer_array < T >& a1,
const pointer_array < T >& a2);
657 template <
typename T1,
typename T2>
658 inline bool contains_array(
const T1& t1,
const T2& t2);
661 template <
typename T1,
typename T2>
662 inline ::collection::count erase_array(T1& t1, T2&& t2);
665 template <
typename T1,
typename T2>
666 inline bool equals_non_unique_unordered(
const T1& t1,
const T2& t2)
669 return ::acme::array::contains_array(t1, t2) && ::acme::array::contains_array(t2, t1);
673 template <
typename A,
typename PTRA >
674 void ptra(PTRA& ptra,
const A& a)
680 ptra.add((
typename PTRA::BASE_TYPE) item);
687 template <
typename A >
688 ::array < const_char_pointer >psza(
const A& a)
691 ::array < const_char_pointer >pa;
702 template <
typename A,
typename PA >
703 void copy_points(A& a,
const PA* pa, ::collection::count c);
711 template <
typename A >
712 ::collection::count predominant_column_count(A& a);
717 template <
typename TYPE, ::enum_type t_etypeContainer = e_type_element >
718 ::collection::count erase_greater_than(::numeric_array_base < TYPE, t_etypeContainer >& a, TYPE hi);
721 template <
typename TYPE, ::enum_type t_etypeContainer = e_type_element >
722 ::collection::count erase_greater_than_or_equal(::numeric_array_base < TYPE, t_etypeContainer >& a, TYPE hi);
725 template <
typename TYPE, ::enum_type t_etypeContainer = e_type_element >
726 ::collection::count erase_lesser_than(::numeric_array_base < TYPE, t_etypeContainer >& a, TYPE lo);
729 template <
typename TYPE, ::enum_type t_etypeContainer = e_type_element >
730 ::collection::count erase_lesser_than_or_equal(::numeric_array_base < TYPE, t_etypeContainer >& a, TYPE lo);
733 template <
typename TYPE, ::enum_type t_etypeContainer = e_type_element >
734 ::collection::count erase_lesser_than_or_greater_than(::numeric_array_base < TYPE, t_etypeContainer >& a, TYPE lo, TYPE hi);
737 template <
typename TYPE, ::enum_type t_etypeContainer = e_type_element >
738 ::collection::count erase_lesser_than_or_greater_than_or_equal(::numeric_array_base < TYPE, t_etypeContainer >& a, TYPE lo, TYPE hi);
741 template <
typename TYPE, ::enum_type t_etypeContainer = e_type_element >
742 ::collection::count erase_lesser_than_or_equal_or_greater_than(::numeric_array_base < TYPE, t_etypeContainer >& a, TYPE lo, TYPE hi);
745 template <
typename TYPE, ::enum_type t_etypeContainer = e_type_element >
746 ::collection::count erase_lesser_than_or_equal_or_greater_than_or_equal(::numeric_array_base < TYPE, t_etypeContainer >& a, TYPE lo, TYPE hi);
937 template <
typename Type,
typename RawType, ::enum_type t_etypeContainer >
938 ::collection::index add(string_base_array < Type, RawType, t_etypeContainer >& array, const ::payload& payload)
941 ::collection::index i = -1;
943 if (payload.is_empty())
947 else if (payload.get_type() == ::e_type_string_array)
950 i = ::acme::array::add(array, payload.as_string_array());
953 else if (payload.cast < string_base_array < Type, RawType, t_etypeContainer > >() !=
nullptr)
956 i = ::acme::array::add(array, *payload.cast < string_base_array < Type, RawType, t_etypeContainer > >());
959 else if (payload.get_type() == ::e_type_payload_array)
962 for (::collection::index i = 0; i < payload.as_payload_array().get_count(); i++)
965 ::collection::index iItem = ::acme::array::add(array, payload.as_payload_array()[i]);
977 else if (payload.get_type() == ::e_type_int_array)
980 array.copy(payload.as_int_array());
983 else if (payload.get_type() == ::e_type_property_set)
986 auto & set = payload.property_set_reference();
988 for (
auto& property : set)
991 auto iItem = ::acme::array::add(array, property);
1006 i = ::acme::array::add(array, payload);
1055 template <
class TDST,
class TSRC >
1056 ::collection::count copy(TDST& dsta,
const TSRC& srca)
1061 for (::i32 i = 0; i < srca.get_size(); i++)
1064 dsta.add((
typename TDST::BASE_TYPE) srca[i]);
1068 return dsta.get_count();
1077 template <
typename CONTAINER,
class TYPE >
1078 bool contains_item(
const CONTAINER& container,
const TYPE& t)
1081 for (
auto& item : container)
1099 template <
typename T1,
typename T2>
1100 inline bool contains_array(
const T1& t1,
const T2& t2)
1106 if (!contains_item(t1, t))
1122 template <
class TINTERSECTION,
class TDST,
class TSRC >
1123 void intersection(TINTERSECTION& intersection,
const TDST& dsta,
const TSRC& srca)
1126 intersection.clear();
1128 for (
auto& item : dsta)
1131 if (contains_item(srca, item))
1134 intersection.add(item);
1142 template <
typename T1,
typename T2>
1143 inline ::collection::count erase_array(T1& t1, T2&& t2)
1146 ::collection::count c = 0;
1201 template <
typename A,
typename PA >
1202 void copy_points(A& a,
const PA* pa, ::collection::count c)
1207 for (::collection::index i = 0; i < c; i++)
1210 a[i] = (
typename A::BASE_TYPE) pa[i];
1219 template <
class TDST,
class TSRC >
1220 ::collection::count copy(pointer_array < TDST >& dsta,
const pointer_array < TSRC >& srca)
1223 ::collection::count ca = 0;
1227 for (::i32 i = 0; i < srca.get_size(); i++)
1229 dsta.
add(allocateø TSRC(srca(i)));
1240 template <
class TDST,
class TSRC >
1241 ::collection::count copy(address_array_base < TDST >& dsta,
const address_array_base < TSRC >& srca)
1244 ::collection::count ca = 0;
1248 for (::i32 i = 0; i < srca.get_size(); i++)
1250 dsta.add(___new TSRC (srca(i)));
1258 template <
class TDST,
class TSRC >
1259 ::collection::count ptrcopy(TDST& dsta,
const TSRC& srca)
1262 ::collection::count ca = 0;
1266 for (::i32 i = 0; i < srca.get_size(); i++)
1279 template <
class A,
class A2D >
1280 void array_permute(A2D& perm,
const A& a)
1282 ::collection::count count = a.get_count();
1291 for (::i32 i = 0; i < count; i++)
1295 topermut.erase_all();
1296 for (::i32 j = 0; j < i; j++)
1300 for (::i32 j = i + 1; j < count; j++)
1305 array_permute(perm2, topermut);
1306 for (::i32 j = 0; j < perm2.get_count(); j++)
1308 perm.add(elema + perm2[j]);
1313 template <
class A >
1314 void array_permute(pointer_array < A >& perm,
const A& a)
1316 ::collection::count count = a.get_count();
1319 perm.
add(allocateø A(a));
1324 pointer_array < A > perm2;
1325 for (::i32 i = 0; i < count; i++)
1329 topermut.erase_all();
1330 for (::i32 j = 0; j < i; j++)
1334 for (::i32 j = i + 1; j < count; j++)
1339 array_permute(perm2, topermut);
1340 for (::i32 j = 0; j < perm2.get_count(); j++)
1342 perm.
add(allocateø A(elema + perm2[j]));
1509 template<
class ARRAY>
1510 bool binary_search(ARRAY& a,
typename ARRAY::BASE_ARG_TYPE t, ::collection::index& iIndex, ::collection::index(*fCompare) (
typename ARRAY::BASE_ARG_TYPE,
typename ARRAY::BASE_ARG_TYPE))
1513 if (a.get_size() == 0)
1518 ::collection::index iLowerBound = 0;
1519 ::collection::index iMaxBound = a.get_upper_bound();
1520 ::collection::index iUpperBound = iMaxBound;
1521 ::collection::index iCompare;
1523 iIndex = (iUpperBound + iLowerBound) / 2;
1524 while (iUpperBound - iLowerBound >= 8)
1526 iCompare = fCompare(a.element_at(iIndex), t);
1531 else if (iCompare > 0)
1533 iUpperBound = iIndex - 1;
1534 if (iUpperBound < 0)
1542 iLowerBound = iIndex + 1;
1543 if (iLowerBound > iMaxBound)
1545 iIndex = iMaxBound + 1;
1549 iIndex = (iUpperBound + iLowerBound) / 2;
1552 while (iIndex < a.get_count())
1554 iCompare = fCompare(a.element_at(iIndex), t);
1557 else if (iCompare < 0)
1562 if (iIndex >= a.get_count())
1566 iCompare = fCompare(a.element_at(iIndex), t);
1569 else if (iCompare > 0)
1580 template<
class ARRAY>
1581 bool binary_search(ARRAY& a,
typename ARRAY::BASE_ARG_TYPE t, ::collection::index& iIndex, less_predicate_base < typename ARRAY::BASE_ARG_TYPE >* pless, index_array& ia)
1584 if (a.get_size() == 0)
1591 ::collection::index iLowerBound = 0;
1592 ::collection::index iMaxBound = a.get_upper_bound();
1593 ::collection::index iUpperBound = iMaxBound;
1594 ::collection::index iCompare;
1597 iIndex = (iUpperBound + iLowerBound) / 2;
1599 while (iUpperBound - iLowerBound >= 8)
1602 iCompare = pless->less(a.element_at(iIndex), t);
1610 else if (iCompare > 0)
1613 iUpperBound = iIndex - 1;
1615 if (iUpperBound < 0)
1628 iLowerBound = iIndex + 1;
1630 if (iLowerBound > iMaxBound)
1633 iIndex = iMaxBound + 1;
1641 iIndex = (iUpperBound + iLowerBound) / 2;
1646 while (iIndex < a.get_count())
1649 iCompare = pless->less(a.element_at(iIndex), t);
1658 else if (iCompare < 0)
1673 if (iIndex >= a.get_count())
1683 iCompare = pless->less(a.element_at(iIndex), t);
1692 else if (iCompare > 0)
1714 template <
typename TYPE, ::enum_type t_etypeContainer >
1715 ::collection::count append_sequence(::numeric_array_base < TYPE, t_etypeContainer >& a, TYPE iterator, TYPE end, TYPE increment)
1723 else if (increment > 0)
1725 ::collection::count ca = 0;
1726 for (; iterator <= end; iterator += increment)
1735 ::collection::count ca = 0;
1736 for (; iterator >= end; iterator += increment)
1746 template <
typename TYPE, ::enum_type t_etypeContainer >
1747 ::collection::count set_sequence(::numeric_array_base < TYPE, t_etypeContainer >& a, TYPE start, TYPE end, TYPE increment)
1750 return append_sequence(a, start, end, increment);
1754 template <
typename ARRAY >
1755 inline typename ARRAY::BASE_TYPE pop(ARRAY& a, ::collection::index n)
1758 ::collection::index i = a.get_upper_bound(n);
1760 typename ARRAY::TYPE t = a.element_at(i);
1769 template <
typename ARRAY >
1770 inline void pop_back(ARRAY& a, ::collection::index n)
1773 a.erase_at(a.get_upper_bound(n));
1778 template <
typename ARRAY >
1779 inline ::collection::index push(ARRAY& a,
typename ARRAY::BASE_ARG_TYPE newElement, ::collection::index n)
1782 return a.insert_at(a.get_upper_bound(n), newElement);
1787 template <
typename ARRAY >
1788 inline void add(ARRAY& a,
typename ARRAY::BASE_ARG_TYPE newElement, ::collection::index n)
1791 a.insert_at(a.get_upper_bound(n), newElement);
1812 template <
typename A >
1813 ::collection::count predominant_column_count(A& a)
1816 index_to_index column_count;
1818 for (::collection::index i = 0; i < a.get_size(); i++)
1821 column_count[a[i].get_count()]++;
1825 ::collection::count c = -1;
1827 ::collection::count cMax = -1;
1829 for (
auto& assoc : column_count)
1832 if (assoc.element2() > cMax || (assoc.element2() == cMax && assoc.element1() > c))
1835 c = assoc.element1();
1837 cMax = assoc.element2();
::collection::index add(const pointer< T > &p)
consumes a referer
Definition pointer_array.h:226
include "aura/graphics/image/context.h"
Definition aaaa__defer.h:32