|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Ordered set stored as a sorted contiguous array. More...
#include <tpl_flat_set.H>
Public Types | |
| using | Item_Type = Key |
| Aleph convention: element type. | |
| using | Key_Type = Key |
| Aleph convention: key type. | |
| using | key_type = Key |
| STL convention: key type. | |
| using | value_type = Key |
| STL convention: value type. | |
| using | key_compare = Compare |
| STL convention: comparator type. | |
| using | size_type = size_t |
| STL convention: size type. | |
| using | iterator = const Key * |
| Random-access iterator (immutable). | |
| using | const_iterator = const Key * |
| Random-access const iterator. | |
Public Member Functions | |
| FlatSet (size_t cap=MemArray< Key >::Min_Dim) | |
| Construct an empty set. | |
| FlatSet (const Compare &cmp, size_t cap=MemArray< Key >::Min_Dim) | |
| Construct an empty set with a specific comparator. | |
| template<std::input_iterator It> | |
| FlatSet (It first, It last, const Compare &cmp=Compare()) | |
| Construct from an iterator range. | |
| FlatSet (std::initializer_list< Key > l, const Compare &cmp=Compare()) | |
| Construct from an initializer list. | |
| FlatSet (const FlatSet &)=default | |
Copy constructor (requires copyable Key). | |
| FlatSet (FlatSet &&) noexcept=default | |
| Move constructor. The source is left valid but unspecified. | |
| FlatSet & | operator= (const FlatSet &)=default |
Copy assignment (requires copyable Key). | |
| FlatSet & | operator= (FlatSet &&) noexcept=default |
| Move assignment. The source is left valid but unspecified. | |
| ~FlatSet ()=default | |
| void | swap (FlatSet &s) noexcept(std::is_nothrow_swappable_v< Compare >) |
Swap contents with s in O(1). | |
| size_t | size () const noexcept |
| Return the number of stored keys. O(1). | |
| bool | is_empty () const noexcept |
Return true if the set holds no keys. O(1). | |
| size_t | capacity () const noexcept |
| Return the capacity of the backing array. O(1). | |
| void | reserve (size_t cap) |
Reserve capacity for at least cap keys. | |
| void | empty () noexcept |
| Remove all keys (Aleph convention). | |
| void | clear () noexcept |
Remove all keys. Alias of empty(). Capacity is kept. | |
| const_iterator | find (const Key &k) const |
| Find a key. | |
| bool | contains (const Key &k) const |
| Test membership. | |
| size_t | count (const Key &k) const |
| Count occurrences of a key (0 or 1). | |
| const_iterator | lower_bound (const Key &k) const |
First element not less than k. | |
| const_iterator | upper_bound (const Key &k) const |
First element greater than k. | |
| std::pair< const_iterator, const_iterator > | equal_range (const Key &k) const |
Range of elements equivalent to k. | |
| const Key & | nth (size_t i) const |
| Positional access to the i-th smallest key (checked). | |
| const Key & | operator() (size_t i) const noexcept |
| Positional access without bounds checking. | |
| const Key & | get_first () const |
| Smallest key (checked). | |
| const Key & | get_last () const |
| Greatest key (checked). | |
| const Key & | min () const |
Smallest key (checked). Alias of get_first(). | |
| const Key & | max () const |
Greatest key (checked). Alias of get_last(). | |
| std::pair< const_iterator, bool > | insert (const Key &k) |
Insert a copy of k if no equivalent key exists. | |
| std::pair< const_iterator, bool > | insert (Key &&k) |
Insert k by moving if no equivalent key exists. | |
| template<class... Args> | |
| std::pair< const_iterator, bool > | emplace (Args &&...args) |
| Construct a key in place and insert it. | |
| size_t | erase (const Key &k) |
Remove the key equivalent to k, if present. | |
| const_iterator | erase (const_iterator it) |
Remove the key at iterator it. | |
| const_iterator | begin () const noexcept |
| Iterator to the smallest key. O(1). | |
| const_iterator | end () const noexcept |
| Iterator past the greatest key. O(1). | |
| const_iterator | cbegin () const noexcept |
| Const iterator to the smallest key. O(1). | |
| const_iterator | cend () const noexcept |
| Const iterator past the greatest key. O(1). | |
| const Key * | data () const noexcept |
| Pointer to the underlying sorted, contiguous storage. O(1). | |
| template<class Operation > | |
| bool | traverse (Operation operation) const |
Traverse keys in sorted order while operation returns true. | |
| bool | operator== (const FlatSet &s) const |
| Equality: same size and pairwise equal elements. | |
| bool | operator!= (const FlatSet &s) const |
Inequality: negation of operator==. | |
Private Member Functions | |
| size_t | lower_idx (const Key &k) const |
| size_t | upper_idx (const Key &k) const |
| bool | match_at (size_t pos, const Key &k) const |
| void | make_room (const size_t pos) |
| void | remove_at (const size_t pos) |
| void | sort_and_unique () |
Private Attributes | |
| MemArray< Key > | keys_ |
| Compare | cmp_ |
Ordered set stored as a sorted contiguous array.
Keys are kept sorted according to Compare inside a MemArray<Key>. All lookup operations are binary searches over contiguous memory; all mutating operations preserve the sorted invariant by shifting elements.
Duplicate keys (keys equivalent under Compare) are not stored: an insertion of an equivalent key leaves the set unchanged.
| Key | Type of the stored keys. Must be default-constructible, move-constructible and move-assignable (requirements inherited from MemArray). |
| Compare | Strict weak ordering over Key. Defaults to Aleph::less<Key>. |
const Key * pointers (contiguous, random access). As with std::set, elements are immutable through iterators: mutating a key in place would break the sorted invariant. Any insertion or removal invalidates all iterators.Array), empty() clears the container and is_empty() is the emptiness predicate.insert offers the strong guarantee up to the element shift: if the key copy/move assignment throws mid-shift, the guarantee degrades to basic (the container remains valid, contents unspecified). erase always removes the element; a failed shrinking reallocation is ignored.Definition at line 128 of file tpl_flat_set.H.
| using Aleph::FlatSet< Key, Compare >::const_iterator = const Key * |
Random-access const iterator.
Definition at line 224 of file tpl_flat_set.H.
| using Aleph::FlatSet< Key, Compare >::Item_Type = Key |
Aleph convention: element type.
Definition at line 217 of file tpl_flat_set.H.
| using Aleph::FlatSet< Key, Compare >::iterator = const Key * |
Random-access iterator (immutable).
Definition at line 223 of file tpl_flat_set.H.
| using Aleph::FlatSet< Key, Compare >::key_compare = Compare |
STL convention: comparator type.
Definition at line 221 of file tpl_flat_set.H.
| using Aleph::FlatSet< Key, Compare >::Key_Type = Key |
Aleph convention: key type.
Definition at line 218 of file tpl_flat_set.H.
| using Aleph::FlatSet< Key, Compare >::key_type = Key |
STL convention: key type.
Definition at line 219 of file tpl_flat_set.H.
| using Aleph::FlatSet< Key, Compare >::size_type = size_t |
STL convention: size type.
Definition at line 222 of file tpl_flat_set.H.
| using Aleph::FlatSet< Key, Compare >::value_type = Key |
STL convention: value type.
Definition at line 220 of file tpl_flat_set.H.
|
inlineexplicit |
Construct an empty set.
| cap | Initial capacity hint (rounded up to a power of two by the backing MemArray). |
| std::bad_alloc | if the initial buffer cannot be allocated. |
Definition at line 232 of file tpl_flat_set.H.
|
inlineexplicit |
Construct an empty set with a specific comparator.
| cmp | Comparator instance to copy. |
| cap | Initial capacity hint. |
| std::bad_alloc | if the initial buffer cannot be allocated. |
Definition at line 240 of file tpl_flat_set.H.
|
inline |
Construct from an iterator range.
Loads all elements, then sorts once and removes duplicates: O(m log m) for m input elements, which beats m individual O(n) insertions.
| It | Input iterator whose value type converts to Key. |
| first | Beginning of the range. |
| last | End of the range. |
| cmp | Comparator instance (defaulted). |
| std::bad_alloc | if memory allocation fails. |
Definition at line 256 of file tpl_flat_set.H.
References Aleph::FlatSet< Key, Compare >::keys_, Aleph::MemArray< T >::put(), and Aleph::FlatSet< Key, Compare >::sort_and_unique().
|
inline |
Construct from an initializer list.
| l | Elements to load; duplicates are dropped (first wins). |
| cmp | Comparator instance (defaulted). |
| std::bad_alloc | if memory allocation fails. |
Definition at line 270 of file tpl_flat_set.H.
|
default |
Copy constructor (requires copyable Key).
|
defaultnoexcept |
Move constructor. The source is left valid but unspecified.
|
default |
|
inlinenoexcept |
Iterator to the smallest key. O(1).
Definition at line 540 of file tpl_flat_set.H.
References Aleph::MemArray< T >::get_ptr(), and Aleph::FlatSet< Key, Compare >::keys_.
Referenced by Aleph::FlatSet< Key, Compare >::cbegin(), Aleph::FlatSet< Key, Compare >::erase(), Aleph::FlatSet< Key, Compare >::find(), Aleph::FlatSet< Key, Compare >::insert(), Aleph::FlatSet< Key, Compare >::insert(), Aleph::FlatSet< Key, Compare >::lower_bound(), Aleph::FlatSet< Key, Compare >::operator==(), TEST(), TEST(), TEST(), TEST(), and Aleph::FlatSet< Key, Compare >::upper_bound().
|
inlinenoexcept |
Return the capacity of the backing array. O(1).
Definition at line 312 of file tpl_flat_set.H.
References Aleph::MemArray< T >::capacity(), and Aleph::FlatSet< Key, Compare >::keys_.
Referenced by TEST().
|
inlinenoexcept |
Const iterator to the smallest key. O(1).
Definition at line 552 of file tpl_flat_set.H.
References Aleph::FlatSet< Key, Compare >::begin().
|
inlinenoexcept |
Const iterator past the greatest key. O(1).
Definition at line 558 of file tpl_flat_set.H.
References Aleph::FlatSet< Key, Compare >::end().
|
inlinenoexcept |
Remove all keys. Alias of empty(). Capacity is kept.
Definition at line 336 of file tpl_flat_set.H.
References Aleph::MemArray< T >::clear(), and Aleph::FlatSet< Key, Compare >::keys_.
Referenced by TEST().
|
inline |
Test membership.
| k | Key to search for. |
true if an equivalent key is stored. Definition at line 359 of file tpl_flat_set.H.
References k, Aleph::FlatSet< Key, Compare >::lower_idx(), and Aleph::FlatSet< Key, Compare >::match_at().
Referenced by Aleph::FlatSet< Key, Compare >::count(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().
|
inline |
Count occurrences of a key (0 or 1).
| k | Key to search for. |
Definition at line 369 of file tpl_flat_set.H.
References Aleph::FlatSet< Key, Compare >::contains(), and k.
Referenced by TEST().
|
inlinenoexcept |
Pointer to the underlying sorted, contiguous storage. O(1).
Definition at line 564 of file tpl_flat_set.H.
References Aleph::MemArray< T >::get_ptr(), and Aleph::FlatSet< Key, Compare >::keys_.
Referenced by TEST().
|
inline |
Construct a key in place and insert it.
The key is constructed once from args and then moved into position, so this is a convenience over insert(Key(args...)), not a true in-place construction (the sorted position must be searched first).
| Args | Argument types forwarded to Key's constructor. |
| args | Arguments forwarded to Key's constructor. |
| std::bad_alloc | if a growing reallocation fails. |
Definition at line 503 of file tpl_flat_set.H.
References Aleph::blossom_maximum_cardinality_matching(), and Aleph::FlatSet< Key, Compare >::insert().
|
inlinenoexcept |
Remove all keys (Aleph convention).
Capacity is kept.
Array::empty()), this mutates the set; use is_empty() to test for emptiness. Definition at line 330 of file tpl_flat_set.H.
References Aleph::MemArray< T >::empty(), and Aleph::FlatSet< Key, Compare >::keys_.
Referenced by TEST().
|
inlinenoexcept |
Iterator past the greatest key. O(1).
Definition at line 546 of file tpl_flat_set.H.
References Aleph::MemArray< T >::get_ptr(), Aleph::FlatSet< Key, Compare >::keys_, and Aleph::MemArray< T >::size().
Referenced by Aleph::FlatSet< Key, Compare >::cend(), Aleph::FlatSet< Key, Compare >::find(), Aleph::FlatSet< Key, Compare >::operator==(), TEST(), TEST(), TEST(), TEST(), and TEST().
|
inline |
Range of elements equivalent to k.
| k | Key to bound. |
{lower_bound(k), upper_bound(k)} (length 0 or 1). Definition at line 399 of file tpl_flat_set.H.
References k, Aleph::FlatSet< Key, Compare >::lower_bound(), and Aleph::FlatSet< Key, Compare >::upper_bound().
Referenced by TEST().
|
inline |
Remove the key equivalent to k, if present.
| k | Key to remove. |
Definition at line 514 of file tpl_flat_set.H.
References Aleph::blossom_maximum_cardinality_matching(), k, Aleph::FlatSet< Key, Compare >::lower_idx(), Aleph::FlatSet< Key, Compare >::match_at(), and Aleph::FlatSet< Key, Compare >::remove_at().
|
inline |
Remove the key at iterator it.
| it | Valid dereferenceable iterator into this set. |
| std::out_of_range | if it does not point into the set. |
Definition at line 529 of file tpl_flat_set.H.
References ah_out_of_range_error_if, Aleph::FlatSet< Key, Compare >::begin(), Aleph::FlatSet< Key, Compare >::remove_at(), and Aleph::FlatSet< Key, Compare >::size().
|
inline |
Find a key.
| k | Key to search for. |
end() if absent. Definition at line 348 of file tpl_flat_set.H.
References Aleph::FlatSet< Key, Compare >::begin(), Aleph::FlatSet< Key, Compare >::end(), k, Aleph::FlatSet< Key, Compare >::lower_idx(), and Aleph::FlatSet< Key, Compare >::match_at().
|
inline |
Smallest key (checked).
| std::underflow_error | if the set is empty. |
Definition at line 428 of file tpl_flat_set.H.
References ah_underflow_error_if, Aleph::FlatSet< Key, Compare >::is_empty(), and Aleph::FlatSet< Key, Compare >::keys_.
Referenced by Aleph::FlatSet< Key, Compare >::min(), and TEST().
|
inline |
Greatest key (checked).
| std::underflow_error | if the set is empty. |
Definition at line 438 of file tpl_flat_set.H.
References ah_underflow_error_if, Aleph::FlatSet< Key, Compare >::is_empty(), Aleph::FlatSet< Key, Compare >::keys_, and Aleph::MemArray< T >::size().
Referenced by Aleph::FlatSet< Key, Compare >::max(), and TEST().
|
inline |
Insert a copy of k if no equivalent key exists.
| k | Key to insert. |
true if inserted / false if an equivalent key was already present). | std::bad_alloc | if a growing reallocation fails. |
Definition at line 465 of file tpl_flat_set.H.
References Aleph::FlatSet< Key, Compare >::begin(), Aleph::MemArray< T >::get_ptr(), k, Aleph::FlatSet< Key, Compare >::keys_, Aleph::FlatSet< Key, Compare >::lower_idx(), Aleph::FlatSet< Key, Compare >::make_room(), and Aleph::FlatSet< Key, Compare >::match_at().
Referenced by Aleph::FlatSet< Key, Compare >::emplace(), TEST(), TEST(), TEST(), and TEST().
|
inline |
Insert k by moving if no equivalent key exists.
| k | Key to move in. |
| std::bad_alloc | if a growing reallocation fails. |
Definition at line 481 of file tpl_flat_set.H.
References Aleph::FlatSet< Key, Compare >::begin(), Aleph::MemArray< T >::get_ptr(), k, Aleph::FlatSet< Key, Compare >::keys_, Aleph::FlatSet< Key, Compare >::lower_idx(), Aleph::FlatSet< Key, Compare >::make_room(), and Aleph::FlatSet< Key, Compare >::match_at().
|
inlinenoexcept |
Return true if the set holds no keys. O(1).
Definition at line 306 of file tpl_flat_set.H.
References Aleph::MemArray< T >::is_empty(), and Aleph::FlatSet< Key, Compare >::keys_.
Referenced by Aleph::FlatSet< Key, Compare >::get_first(), Aleph::FlatSet< Key, Compare >::get_last(), TEST(), and TEST().
|
inline |
First element not less than k.
| k | Key to bound. |
e with not cmp(e, k), or end(). Definition at line 379 of file tpl_flat_set.H.
References Aleph::FlatSet< Key, Compare >::begin(), k, and Aleph::FlatSet< Key, Compare >::lower_idx().
Referenced by Aleph::FlatSet< Key, Compare >::equal_range(), and TEST().
|
inlineprivate |
Definition at line 134 of file tpl_flat_set.H.
References Aleph::blossom_maximum_cardinality_matching(), Aleph::FlatSet< Key, Compare >::cmp_, k, Aleph::FlatSet< Key, Compare >::keys_, and Aleph::MemArray< T >::size().
Referenced by Aleph::FlatSet< Key, Compare >::contains(), Aleph::FlatSet< Key, Compare >::erase(), Aleph::FlatSet< Key, Compare >::find(), Aleph::FlatSet< Key, Compare >::insert(), Aleph::FlatSet< Key, Compare >::insert(), and Aleph::FlatSet< Key, Compare >::lower_bound().
|
inlineprivate |
Definition at line 165 of file tpl_flat_set.H.
References Aleph::MemArray< T >::get_ptr(), Aleph::FlatSet< Key, Compare >::keys_, Aleph::MemArray< T >::putn(), and Aleph::MemArray< T >::size().
Referenced by Aleph::FlatSet< Key, Compare >::insert(), and Aleph::FlatSet< Key, Compare >::insert().
|
inlineprivate |
Definition at line 159 of file tpl_flat_set.H.
References Aleph::and, Aleph::blossom_maximum_cardinality_matching(), Aleph::FlatSet< Key, Compare >::cmp_, k, Aleph::FlatSet< Key, Compare >::keys_, and Aleph::MemArray< T >::size().
Referenced by Aleph::FlatSet< Key, Compare >::contains(), Aleph::FlatSet< Key, Compare >::erase(), Aleph::FlatSet< Key, Compare >::find(), Aleph::FlatSet< Key, Compare >::insert(), and Aleph::FlatSet< Key, Compare >::insert().
|
inline |
Greatest key (checked). Alias of get_last().
Definition at line 451 of file tpl_flat_set.H.
References Aleph::FlatSet< Key, Compare >::get_last().
Referenced by TEST().
|
inline |
Smallest key (checked). Alias of get_first().
Definition at line 445 of file tpl_flat_set.H.
References Aleph::FlatSet< Key, Compare >::get_first().
Referenced by TEST().
|
inline |
Positional access to the i-th smallest key (checked).
| i | Zero-based rank. |
| std::out_of_range | if i >= size(). |
Definition at line 410 of file tpl_flat_set.H.
References Aleph::FlatSet< Key, Compare >::keys_.
|
inline |
Inequality: negation of operator==.
Definition at line 602 of file tpl_flat_set.H.
References Aleph::blossom_maximum_cardinality_matching().
|
inlinenoexcept |
Positional access without bounds checking.
| i | Zero-based rank (must be < size()). |
Definition at line 419 of file tpl_flat_set.H.
References Aleph::FlatSet< Key, Compare >::keys_.
|
default |
Copy assignment (requires copyable Key).
|
defaultnoexcept |
Move assignment. The source is left valid but unspecified.
|
inline |
Equality: same size and pairwise equal elements.
| s | Set to compare against. |
true if both sets hold equal elements in the same order. Key to be equality comparable. Definition at line 596 of file tpl_flat_set.H.
References Aleph::and, Aleph::FlatSet< Key, Compare >::begin(), Aleph::FlatSet< Key, Compare >::end(), and Aleph::FlatSet< Key, Compare >::size().
|
inlineprivate |
Definition at line 175 of file tpl_flat_set.H.
References Aleph::blossom_maximum_cardinality_matching(), Aleph::MemArray< T >::get(), Aleph::MemArray< T >::get_ptr(), Aleph::FlatSet< Key, Compare >::keys_, and Aleph::MemArray< T >::size().
Referenced by Aleph::FlatSet< Key, Compare >::erase(), and Aleph::FlatSet< Key, Compare >::erase().
|
inline |
Reserve capacity for at least cap keys.
| cap | Desired capacity (rounded up to a power of two). |
| std::bad_alloc | if memory allocation fails. |
Definition at line 321 of file tpl_flat_set.H.
References Aleph::FlatSet< Key, Compare >::keys_, and Aleph::MemArray< T >::reserve().
Referenced by TEST().
|
inlinenoexcept |
Return the number of stored keys. O(1).
Definition at line 300 of file tpl_flat_set.H.
References Aleph::FlatSet< Key, Compare >::keys_, and Aleph::MemArray< T >::size().
Referenced by Aleph::FlatSet< Key, Compare >::erase(), Aleph::FlatSet< Key, Compare >::operator==(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().
|
inlineprivate |
Definition at line 194 of file tpl_flat_set.H.
References Aleph::blossom_maximum_cardinality_matching(), Aleph::FlatSet< Key, Compare >::cmp_, Aleph::MemArray< T >::get(), Aleph::MemArray< T >::get_ptr(), Aleph::FlatSet< Key, Compare >::keys_, m, Aleph::MemArray< T >::size(), and Aleph::timsort().
Referenced by Aleph::FlatSet< Key, Compare >::FlatSet().
|
inlinenoexcept |
Swap contents with s in O(1).
| s | Set to swap with. |
Definition at line 291 of file tpl_flat_set.H.
References Aleph::FlatSet< Key, Compare >::cmp_, Aleph::FlatSet< Key, Compare >::keys_, and Aleph::MemArray< T >::swap().
Referenced by TEST().
|
inline |
Traverse keys in sorted order while operation returns true.
Aleph-style bounded traversal: operation receives each key (as const Key &) in ascending order; returning false stops the walk.
| Operation | Callable bool(const Key &). |
| operation | Operation to apply. |
true if all keys were visited, false if stopped early. Definition at line 579 of file tpl_flat_set.H.
References Aleph::blossom_maximum_cardinality_matching(), Aleph::MemArray< T >::get_ptr(), Aleph::FlatSet< Key, Compare >::keys_, m, and Aleph::MemArray< T >::size().
Referenced by TEST().
|
inline |
First element greater than k.
| k | Key to bound. |
e with cmp(k, e), or end(). Definition at line 389 of file tpl_flat_set.H.
References Aleph::FlatSet< Key, Compare >::begin(), k, and Aleph::FlatSet< Key, Compare >::upper_idx().
Referenced by Aleph::FlatSet< Key, Compare >::equal_range(), and TEST().
|
inlineprivate |
Definition at line 146 of file tpl_flat_set.H.
References Aleph::blossom_maximum_cardinality_matching(), Aleph::FlatSet< Key, Compare >::cmp_, k, Aleph::FlatSet< Key, Compare >::keys_, and Aleph::MemArray< T >::size().
Referenced by Aleph::FlatSet< Key, Compare >::upper_bound().
|
private |
|
private |
Definition at line 130 of file tpl_flat_set.H.
Referenced by Aleph::FlatSet< Key, Compare >::FlatSet(), Aleph::FlatSet< Key, Compare >::begin(), Aleph::FlatSet< Key, Compare >::capacity(), Aleph::FlatSet< Key, Compare >::clear(), Aleph::FlatSet< Key, Compare >::data(), Aleph::FlatSet< Key, Compare >::empty(), Aleph::FlatSet< Key, Compare >::end(), Aleph::FlatSet< Key, Compare >::get_first(), Aleph::FlatSet< Key, Compare >::get_last(), Aleph::FlatSet< Key, Compare >::insert(), Aleph::FlatSet< Key, Compare >::insert(), Aleph::FlatSet< Key, Compare >::is_empty(), Aleph::FlatSet< Key, Compare >::lower_idx(), Aleph::FlatSet< Key, Compare >::make_room(), Aleph::FlatSet< Key, Compare >::match_at(), Aleph::FlatSet< Key, Compare >::nth(), Aleph::FlatSet< Key, Compare >::operator()(), Aleph::FlatSet< Key, Compare >::remove_at(), Aleph::FlatSet< Key, Compare >::reserve(), Aleph::FlatSet< Key, Compare >::size(), Aleph::FlatSet< Key, Compare >::sort_and_unique(), Aleph::FlatSet< Key, Compare >::swap(), Aleph::FlatSet< Key, Compare >::traverse(), and Aleph::FlatSet< Key, Compare >::upper_idx().