25#ifndef JAU_DYN_ARRAY_SORTED_HPP_
26#define JAU_DYN_ARRAY_SORTED_HPP_
59 template <
typename Value_type,
typename Size_type = jau::n
size_t,
typename Alloc_type = jau::callocator<Value_type>,
60 bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>,
61 bool use_secmem = is_enforcing_secmem_v<Value_type>
70 using darray_type::operator[];
129 if( l == h && (*
this)[h] < x ) { h++; }
130 else if( (*
this)[l] > x ) { h=l; }
131 else if( (*
this)[h] < x ) { l=h; h++; }
132 else if( (*
this)[l] == x ) {
return l; }
133 else if( (*
this)[h] == x ) {
return h; }
135 if( l == h && (*
this)[h] > x ) { h++; }
136 else if( (*
this)[l] < x ) { h=l; }
137 else if( (*
this)[h] > x ) { l=h; h++; }
138 else if( (*
this)[l] == x ) {
return l; }
139 else if( (*
this)[h] == x ) {
return h; }
144 if ( (*
this)[i] < x ) {
145 if ( m_order==
UP ) l=i;
147 }
else if ( (*
this)[i] > x ) {
148 if ( m_order==
UP ) h=i;
Extension to darray resulting in a sorted darray via insert().
constexpr size_type size() const noexcept
Like std::vector::size().
darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem > darray_type
darray_sorted(order_t order=UP)
static constexpr const size_type npos
Special value representing maximal value of size_type, used to denote an invalid index position retur...
size_type insert(const value_type &a)
bool contains(const value_type &x) const noexcept
darray_sorted & operator=(const darray_sorted &m)
darray_sorted(const darray_sorted &m)
size_type index_of(const value_type &x) const
Returns index of given element if found or npos.
Implementation of a dynamic linear array storage, aka vector.
constexpr darray & operator=(const darray &x)
Like std::vector::operator=(&), assignment.
constexpr size_type size() const noexcept
Like std::vector::size().
constexpr iterator insert(const_iterator pos, const value_type &x)
Like std::vector::insert(), copy.
constexpr iterator erase(const_iterator pos)
Like std::vector::erase(), removes the elements at pos.
constexpr T max(const T x, const T y) noexcept
Returns the maximum of two integrals (w/ branching) in O(1)
__pack(...): Produces MSVC, clang and gcc compatible lead-in and -out macros.