diff --git a/octa/algorithm.h b/octa/algorithm.h index 7f9fe2b..ce7ff1e 100644 --- a/octa/algorithm.h +++ b/octa/algorithm.h @@ -185,21 +185,21 @@ inline R max_element(R range, C compare) { template inline T min(std::initializer_list il) { - return octa::min_element(octa::each(il)).front(); + return octa::min_element(octa::iter(il)).front(); } template inline T min(std::initializer_list il, C compare) { - return octa::min_element(octa::each(il), compare).front(); + return octa::min_element(octa::iter(il), compare).front(); } template inline T max(std::initializer_list il) { - return octa::max_element(octa::each(il)).front(); + return octa::max_element(octa::iter(il)).front(); } template inline T max(std::initializer_list il, C compare) { - return octa::max_element(octa::each(il), compare).front(); + return octa::max_element(octa::iter(il), compare).front(); } /* clamp */ diff --git a/octa/array.h b/octa/array.h index 546bc53..744bb95 100644 --- a/octa/array.h +++ b/octa/array.h @@ -52,18 +52,18 @@ struct Array { Pointer data() { return p_buf; } ConstPointer data() const { return p_buf; } - Range each() { + Range iter() { return Range(p_buf, p_buf + N); } - ConstRange each() const { + ConstRange iter() const { return ConstRange(p_buf, p_buf + N); } - ConstRange ceach() const { + ConstRange citer() const { return ConstRange(p_buf, p_buf + N); } void swap(Array &v) { - octa::swap_ranges(each(), v.each()); + octa::swap_ranges(iter(), v.iter()); } T p_buf[(N > 0) ? N : 1]; diff --git a/octa/initializer_list.h b/octa/initializer_list.h index c3a1e5a..6f937e4 100644 --- a/octa/initializer_list.h +++ b/octa/initializer_list.h @@ -39,12 +39,12 @@ namespace octa { template using InitializerList = std::initializer_list; template -octa::PointerRange each(std::initializer_list init) { +octa::PointerRange iter(std::initializer_list init) { return octa::PointerRange(init.begin(), init.end()); } template -octa::PointerRange ceach(std::initializer_list init) { +octa::PointerRange citer(std::initializer_list init) { return octa::PointerRange(init.begin(), init.end()); } diff --git a/octa/internal/hashtable.h b/octa/internal/hashtable.h index a4111e2..7626501 100644 --- a/octa/internal/hashtable.h +++ b/octa/internal/hashtable.h @@ -182,11 +182,11 @@ private: float p_maxlf; - Range each_from(Chain *c, octa::Size h) { + Range iter_from(Chain *c, octa::Size h) { return Range(p_data.first() + h + 1, p_data.first() + bucket_count(), c); } - ConstRange each_from(Chain *c, octa::Size h) const { + ConstRange iter_from(Chain *c, octa::Size h) const { using RChain = octa::detail::HashChain; return ConstRange((RChain **)(p_data.first() + h + 1), (RChain **)(p_data.first() + bucket_count()), @@ -394,7 +394,7 @@ protected: get_cpalloc() = ht.get_cpalloc(); get_challoc() = ht.get_challoc(); } - for (ConstRange range = ht.each(); !range.empty(); range.pop_front()) + for (ConstRange range = ht.iter(); !range.empty(); range.pop_front()) emplace(range.front()); return *this; } @@ -542,14 +542,14 @@ public: Range find(const K &key) { octa::Size h = 0; Chain *c; - if (find(key, h, c)) return each_from(c, h); + if (find(key, h, c)) return iter_from(c, h); return Range(); } ConstRange find(const K &key) const { octa::Size h = 0; Chain *c; - if (find(key, h, c)) return each_from(c, h); + if (find(key, h, c)) return iter_from(c, h); return ConstRange(); } @@ -587,30 +587,30 @@ public: rehash(octa::Size(ceil(count / max_load_factor()))); } - Range each() { + Range iter() { return Range(p_data.first(), p_data.first() + bucket_count()); } - ConstRange each() const { + ConstRange iter() const { using Chain = octa::detail::HashChain; return ConstRange((Chain **)p_data.first(), (Chain **)(p_data.first() + bucket_count())); } - ConstRange ceach() const { + ConstRange citer() const { using Chain = octa::detail::HashChain; return ConstRange((Chain **)p_data.first(), (Chain **)(p_data.first() + bucket_count())); } - LocalRange each(octa::Size n) { + LocalRange iter(octa::Size n) { if (n >= p_size) return LocalRange(); return LocalRange(p_data.first()[n]); } - ConstLocalRange each(octa::Size n) const { + ConstLocalRange iter(octa::Size n) const { using Chain = octa::detail::HashChain; if (n >= p_size) return ConstLocalRange(); return ConstLocalRange((Chain *)p_data.first()[n]); } - ConstLocalRange ceach(octa::Size n) const { + ConstLocalRange citer(octa::Size n) const { using Chain = octa::detail::HashChain; if (n >= p_size) return ConstLocalRange(); return ConstLocalRange((Chain *)p_data.first()[n]); diff --git a/octa/map.h b/octa/map.h index 0693d8d..a458585 100644 --- a/octa/map.h +++ b/octa/map.h @@ -113,14 +113,14 @@ namespace detail { MapImpl(octa::InitializerList init, octa::Size size = 0, const H &hf = H(), const C &eqf = C(), const A &alloc = A() - ): MapImpl(octa::each(init), size, hf, eqf, alloc) {} + ): MapImpl(octa::iter(init), size, hf, eqf, alloc) {} MapImpl(octa::InitializerList init, octa::Size size, const A &alloc) - : MapImpl(octa::each(init), size, H(), C(), alloc) {} + : MapImpl(octa::iter(init), size, H(), C(), alloc) {} MapImpl(octa::InitializerList init, octa::Size size, const H &hf, const A &alloc - ): MapImpl(octa::each(init), size, hf, C(), alloc) {} + ): MapImpl(octa::iter(init), size, hf, C(), alloc) {} MapImpl &operator=(const MapImpl &m) { Base::operator=(m); diff --git a/octa/range.h b/octa/range.h index cdbc54b..7655eaa 100644 --- a/octa/range.h +++ b/octa/range.h @@ -352,9 +352,9 @@ public: return *this; } - T each() const { return p_range; } + T iter() const { return p_range; } - HalfRange each(const RangeHalf &other) const { + HalfRange iter(const RangeHalf &other) const { return HalfRange(*this, other); } }; @@ -429,36 +429,36 @@ template(*((B *)this), n); } - B each() const { + B iter() const { return B(*((B *)this)); } ReverseRange reverse() const { - return ReverseRange(each()); + return ReverseRange(iter()); } MoveRange movable() const { - return MoveRange(each()); + return MoveRange(iter()); } RangeHalf half() const { - return RangeHalf(each()); + return RangeHalf(iter()); } }; template -auto each(T &r) -> decltype(r.each()) { - return r.each(); +auto iter(T &r) -> decltype(r.iter()) { + return r.iter(); } template -auto each(const T &r) -> decltype(r.each()) { - return r.each(); +auto iter(const T &r) -> decltype(r.iter()) { + return r.iter(); } template -auto ceach(const T &r) -> decltype(r.each()) { - return r.each(); +auto citer(const T &r) -> decltype(r.iter()) { + return r.iter(); } template -PointerRange each(T (&array)[N]) { +PointerRange iter(T (&array)[N]) { return PointerRange(array, N); } @@ -1037,7 +1037,7 @@ ChunksRange chunks(const T &it, RangeSize chs) { } // range of -template using RangeOf = decltype(octa::each(octa::declval())); +template using RangeOf = decltype(octa::iter(octa::declval())); } /* namespace octa */ diff --git a/octa/set.h b/octa/set.h index c97a6e8..7ccbc74 100644 --- a/octa/set.h +++ b/octa/set.h @@ -99,14 +99,14 @@ namespace detail { SetImpl(octa::InitializerList init, octa::Size size = 0, const H &hf = H(), const C &eqf = C(), const A &alloc = A() - ): SetImpl(octa::each(init), size, hf, eqf, alloc) {} + ): SetImpl(octa::iter(init), size, hf, eqf, alloc) {} SetImpl(octa::InitializerList init, octa::Size size, const A &alloc) - : SetImpl(octa::each(init), size, H(), C(), alloc) {} + : SetImpl(octa::iter(init), size, H(), C(), alloc) {} SetImpl(octa::InitializerList init, octa::Size size, const H &hf, const A &alloc - ): SetImpl(octa::each(init), size, hf, C(), alloc) {} + ): SetImpl(octa::iter(init), size, hf, C(), alloc) {} SetImpl &operator=(const SetImpl &m) { Base::operator=(m); diff --git a/octa/string.h b/octa/string.h index ac72a05..b8f9e92 100644 --- a/octa/string.h +++ b/octa/string.h @@ -165,7 +165,7 @@ public: StringBase(const StringBase &s, octa::Size pos, octa::Size len = npos, const A &a = A()): - p_buf(s.p_buf.each().slice(pos, + p_buf(s.p_buf.iter().slice(pos, (len == npos) ? s.p_buf.size() : (pos + len)), a) { terminate(); } @@ -254,7 +254,7 @@ public: StringBase &append(const StringBase &s) { p_buf.pop(); - p_buf.insert_range(p_buf.size(), s.p_buf.each()); + p_buf.insert_range(p_buf.size(), s.p_buf.iter()); return *this; } @@ -309,13 +309,13 @@ public: return strcmp(p_buf.data(), p); } - Range each() { + Range iter() { return Range(p_buf.data(), size()); } - ConstRange each() const { + ConstRange iter() const { return ConstRange(p_buf.data(), size()); } - ConstRange ceach() const { + ConstRange citer() const { return ConstRange(p_buf.data(), size()); } @@ -324,7 +324,7 @@ public: } Size to_hash() const { - return each().to_hash(); + return iter().to_hash(); } A get_allocator() const { @@ -359,7 +359,7 @@ static inline bool operator!=(const char *lhs, const String &rhs) { template String concat(const T &v, const String &sep, F func) { String ret; - auto range = octa::each(v); + auto range = octa::iter(v); if (range.empty()) return ret; for (;;) { ret += func(range.front()); @@ -373,7 +373,7 @@ String concat(const T &v, const String &sep, F func) { template String concat(const T &v, const String &sep = " ") { String ret; - auto range = octa::each(v); + auto range = octa::iter(v); if (range.empty()) return ret; for (;;) { ret += range.front(); @@ -386,12 +386,12 @@ String concat(const T &v, const String &sep = " ") { template String concat(std::initializer_list v, const String &sep, F func) { - return concat(octa::each(v), sep, func); + return concat(octa::iter(v), sep, func); } template String concat(std::initializer_list v, const String &sep = " ") { - return concat(octa::each(v), sep); + return concat(octa::iter(v), sep); } namespace detail { @@ -421,8 +421,8 @@ template struct ToString { !octa::IsScalar::value, bool> = true ) { String ret("{"); - ret += concat(octa::each(v), ", ", ToString>()); ret += "}"; return ret; diff --git a/octa/vector.h b/octa/vector.h index 0706927..e0602f0 100644 --- a/octa/vector.h +++ b/octa/vector.h @@ -382,16 +382,16 @@ public: } Range insert(Size idx, InitializerList il) { - return insert_range(idx, octa::each(il)); + return insert_range(idx, octa::iter(il)); } - Range each() { + Range iter() { return Range(p_buf.first(), p_buf.first() + p_len); } - ConstRange each() const { + ConstRange iter() const { return ConstRange(p_buf.first(), p_buf.first() + p_len); } - ConstRange ceach() const { + ConstRange citer() const { return ConstRange(p_buf.first(), p_buf.first() + p_len); } diff --git a/tests/array.cpp b/tests/array.cpp index 75a0470..332a2e0 100644 --- a/tests/array.cpp +++ b/tests/array.cpp @@ -27,7 +27,7 @@ int main() { assert(x.data()[0] == x[0]); - auto r = x.each(); + auto r = x.iter(); assert(r.front() == 2); assert(r.back() == 32); diff --git a/tests/vector.cpp b/tests/vector.cpp index fa7c9f7..5d0b6b4 100644 --- a/tests/vector.cpp +++ b/tests/vector.cpp @@ -69,12 +69,12 @@ int main() { assert(z[3] == 5); assert(z.size() == 11); - auto r = z.each(); + auto r = z.iter(); assert(r.front() == 5); assert(r.back() == 5); assert(r[2] == 4); - auto r2 = each(z); + auto r2 = iter(z); assert(r.front() == r2.front()); Vector w;