jaulib v1.3.6
Jau Support Library (C++, Java, ..)
|
Extension to darray resulting in a sorted darray via insert(). More...
#include <darray_sorted.hpp>
Public Types | |
typedef darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem > | darray_type |
enum | order_t { UP , DOWN } |
Public Member Functions | |
darray_sorted (const darray_sorted &m) | |
darray_sorted (order_t order=UP) | |
bool | contains (const value_type &x) const noexcept |
constexpr iterator | erase (const size_type first_idx, const size_type last_idx) |
Similar to std::vector::erase() using indices, removes the elements in the range [first_idx, last_idx). | |
constexpr iterator | erase (const size_type pos_idx) |
Similar to std::vector::erase() using an index, removes the elements at pos_idx. | |
constexpr iterator | erase (const_iterator cfirst, const_iterator clast) |
Like std::vector::erase(), removes the elements in the range [first, last). | |
constexpr iterator | erase (const_iterator cpos) |
Like std::vector::erase(), removes the elements at pos. | |
size_type | index_of (const value_type &x) const |
Returns index of given element if found or npos. | |
size_type | insert (const value_type &a) |
darray_sorted & | operator= (const darray_sorted &m) |
constexpr_cxx20 const_reference | operator[] (size_type i) const noexcept |
Like std::vector::operator[](size_type), immutable reference. | |
constexpr_cxx20 reference | operator[] (size_type i) noexcept |
Like std::vector::operator[](size_type), mutable reference. | |
constexpr size_type | size () const noexcept |
Like std::vector::size(). | |
Static Public Attributes | |
static constexpr const size_type | npos = std::numeric_limits<size_type>::max() |
Special value representing maximal value of size_type, used to denote an invalid index position return value, i.e. | |
Additional Inherited Members | |
![]() | |
typedef Alloc_type | allocator_type |
typedef const value_type * | const_iterator |
typedef const value_type * | const_pointer |
typedef const value_type & | const_reference |
typedef bool | darray_tag |
Used to determine whether this type is a darray or has a darray, see is_darray_type<T> | |
typedef std::make_signed_t< size_type > | difference_type |
typedef bool(* | equal_comparator) (const value_type &a, const value_type &b) |
Generic value_type equal comparator to be user defined for e.g. | |
typedef value_type * | iterator |
typedef value_type * | pointer |
typedef value_type & | reference |
typedef darray< value_type, size_type, allocator_type, use_memmove, use_secmem > | self_t |
typedef Size_type | size_type |
typedef Value_type | value_type |
![]() | |
constexpr | darray (darray &parent, pointer begin, pointer position, pointer limit, size_type size) |
Slicing ctor. | |
constexpr | darray () noexcept |
Default constructor, giving zero capacity and zero memory footprint. | |
constexpr | darray (const darray &x) |
Creates a new instance, copying all elements from the given darray. | |
constexpr | darray (const darray &x, const float growth_factor, const allocator_type &alloc) |
Creates a new instance, copying all elements from the given darray. | |
constexpr | darray (const darray &x, const size_type _capacity, const float growth_factor, const allocator_type &alloc) |
Creates a new instance with custom initial storage capacity, copying all elements from the given darray. | |
constexpr | darray (const size_type _capacity, const_iterator first, const_iterator last, const float growth_factor=DEFAULT_GROWTH_FACTOR, const allocator_type &alloc=allocator_type()) |
Creates a new instance with custom initial storage capacity, copying all elements from the given const_iterator value_type range [first, last). | |
template<class InputIt> | |
constexpr | darray (const size_type _capacity, InputIt first, InputIt last, const float growth_factor=DEFAULT_GROWTH_FACTOR, const allocator_type &alloc=allocator_type()) |
Creates a new instance with custom initial storage capacity, copying all elements from the given template input-iterator value_type range [first, last). | |
constexpr | darray (darray &&x) noexcept |
constexpr | darray (darray &&x, const float growth_factor, const allocator_type &alloc) noexcept |
template<class InputIt> | |
constexpr | darray (InputIt first, InputIt last, const allocator_type &alloc=allocator_type()) |
Creates a new instance, copying all elements from the given template input-iterator value_type range [first, last). | |
constexpr | darray (size_type capacity, const float growth_factor=DEFAULT_GROWTH_FACTOR, const allocator_type &alloc=allocator_type()) |
Creating an empty instance with initial capacity and other (default) properties. | |
constexpr | darray (std::initializer_list< value_type > initlist, const allocator_type &alloc=allocator_type()) |
Create a new instance from an initializer list. | |
constexpr | darray (std::nullptr_t, size_type size, value_type value=value_type(), const float growth_factor=DEFAULT_GROWTH_FACTOR, const allocator_type &alloc=allocator_type()) |
Creating a size d instance with initial size elements with default value . | |
~darray () noexcept | |
constexpr void | assign (const_iterator first, const_iterator last) |
Like std::vector::assign(), but non-template overload using const_iterator. | |
template<class InputIt> | |
constexpr void | assign (InputIt first, InputIt last) |
Like std::vector::assign() | |
constexpr_cxx20 reference | at (size_type i) |
Like std::vector::at(size_type), mutable reference. | |
constexpr_cxx20 const_reference | at (size_type i) const |
Like std::vector::at(size_type), immutable reference. | |
constexpr reference | back () |
Like std::vector::back(), mutable access. | |
constexpr const_reference | back () const |
Like std::vector::back(), immutable access. | |
constexpr const_iterator | begin () const noexcept |
constexpr iterator | begin () noexcept |
constexpr size_type | capacity () const noexcept |
Return the current capacity. | |
constexpr bool | capacity_reached () const noexcept |
Returns true if capacity has been reached and the next push_back() will grow the storage and invalidates all iterators and references. | |
constexpr const_iterator | cbegin () const noexcept |
constexpr const_iterator | cend () const noexcept |
const jau::type_info & | classSignature () const noexcept |
Returns type signature of implementing class. | |
constexpr self_t & | clear () noexcept |
Like std::vector::clear(), calls destructor on all elements and leaving capacity unchanged. | |
constexpr self_t & | clear (bool releaseMem) noexcept |
Like std::vector::clear(), calls destructor on all elements. | |
constexpr self_t & | clearPosition () noexcept |
Clears the relative position and limit w/o destructing elements nor mutating storage. | |
constexpr const_pointer | data () const noexcept |
Like std::vector::data(), const immutable pointer. | |
constexpr pointer | data () noexcept |
Like std::vector::data(), mutable pointer. | |
self_t | duplicate () |
Returns a duplicate with same position and limit. | |
template<typename... Args> | |
constexpr iterator | emplace (const_iterator pos, Args &&... args) |
Like std::vector::emplace(), construct a new element in place. | |
template<typename... Args> | |
constexpr reference | emplace_back (Args &&... args) |
Like std::vector::emplace_back(), construct a new element in place at the end(). | |
constexpr bool | empty () const noexcept |
Like std::vector::empty(). | |
constexpr const_iterator | end () const noexcept |
constexpr iterator | end () noexcept |
constexpr iterator | erase (const size_type first_idx, const size_type last_idx) |
Similar to std::vector::erase() using indices, removes the elements in the range [first_idx, last_idx). | |
constexpr iterator | erase (const size_type pos_idx) |
Similar to std::vector::erase() using an index, removes the elements at pos_idx. | |
constexpr iterator | erase (const_iterator cfirst, const_iterator clast) |
Like std::vector::erase(), removes the elements in the range [first, last). | |
constexpr iterator | erase (const_iterator cpos) |
Like std::vector::erase(), removes the elements at pos. | |
template<class UnaryPredicate> | |
constexpr size_type | erase_if (const bool all_matching, UnaryPredicate p) |
Erase either the first matching element or all matching elements. | |
constexpr size_type | erase_matching (const value_type &x, const bool all_matching, equal_comparator comparator) |
Erase either the first matching element or all matching elements using erase(). | |
constexpr self_t & | flip () noexcept |
Sets limit to position and position to zero. | |
constexpr reference | front () |
Like std::vector::front(), mutable access. | |
constexpr const_reference | front () const |
Like std::vector::front(), immutable access. | |
constexpr_cxx20 const_reference | get () |
Relative get() for single value reference, increasing position() by one. | |
allocator_type | get_allocator () const noexcept |
const allocator_type & | get_allocator_ref () const noexcept |
constexpr size_type | get_grown_capacity (size_type add=1) const noexcept |
Return the current capacity() multiplied by the growth factor, minimum is max(capacity()+add, 10). | |
std::string | getInfo () const noexcept |
constexpr float | growthFactor () const noexcept |
Returns growth factor, see setGrowthFactor() for semantics. | |
constexpr bool | hasRemaining () const noexcept |
Returns whether position < limit, i.e. | |
constexpr iterator | insert (const size_type pos_idx, const value_type &x) |
Similar to std::vector::insert() using an index, copy. | |
constexpr iterator | insert (const_iterator pos, const value_type &x) |
Like std::vector::insert(), copy. | |
template<class InputIt> | |
constexpr iterator | insert (const_iterator pos, InputIt first, InputIt last) |
Like std::vector::insert(), inserting the value_type range [first, last). | |
constexpr iterator | insert (const_iterator pos, value_type &&x) |
Like std::vector::insert(), move. | |
constexpr size_type | limit () const noexcept |
Read/write limit, one element beyond maximum index with limit <= size/end. | |
constexpr const_pointer | limit_ptr () const noexcept |
Pointer to immutable read/write limit, one element beyond maximum element with limit <= size/end. | |
constexpr size_type | max_size () const noexcept |
Returns std::numeric_limits<difference_type>::max() as the maximum array size. | |
constexpr darray & | operator= (const darray &x) |
Like std::vector::operator=(&), assignment. | |
constexpr darray & | operator= (darray &&x) noexcept |
Like std::vector::operator=(&&), move. | |
constexpr_cxx20 const_reference | operator[] (size_type i) const noexcept |
Like std::vector::operator[](size_type), immutable reference. | |
constexpr_cxx20 reference | operator[] (size_type i) noexcept |
Like std::vector::operator[](size_type), mutable reference. | |
constexpr bool | pinned () const |
Returns true if growthFactor() < 1, otherwise false. | |
constexpr void | pop_back () noexcept |
Like std::vector::pop_back(). | |
constexpr size_type | position () const noexcept |
Next relative read/write element index, with 0 <= position <= limit. | |
constexpr const_pointer | position_ptr () const noexcept |
Pointer to immutable next relative read/write element index, with 0 <= position <= limit. | |
constexpr pointer | position_ptr () noexcept |
Pointer to mutable next relative read/write element index, with 0 <= position <= limit. | |
constexpr void | push_back (const value_type &x) |
Like std::vector::push_back(), copy. | |
template<class InputIt> | |
constexpr void | push_back (InputIt first, InputIt last) |
Like std::vector::push_back(), but appends the value_type range [first, last). | |
constexpr void | push_back (value_type &&x) |
Like std::vector::push_back(), move. | |
template<typename... Args> | |
constexpr void | push_back_list (Args &&... args) |
Like push_back(), but for more multiple r-value references to move. | |
template<typename... Args> | |
constexpr void | push_back_list (const Args &... args) |
Like push_back(), but for more multiple const r-value to copy. | |
constexpr bool | push_back_unique (const value_type &x, equal_comparator comparator) |
Like std::vector::push_back(), but only if the newly added element does not yet exist. | |
constexpr void | push_front (const value_type &x) |
Like std::vector::push_front(), copy. | |
constexpr void | push_front (value_type &&x) |
Like std::vector::push_front(), move. | |
constexpr_cxx20 self_t & | put (const_reference v, Bool grow=Bool::False) |
Relative put() for single value, increasing position(). | |
template<typename... Targs, std::enable_if_t< jau::is_all_same_v< Targs... > &&sizeof(Value_type) > = sizeof(jau::first_type<Targs...>) && std::is_assignable_v<value_type&, jau::first_type<Targs...>>, bool> | |
constexpr_cxx20 self_t & | putN (Bool grow, const Targs &...args) |
Relative put() for multiple value of an assignable type fitting into value_type, increasing position(). | |
constexpr size_type | remaining () const noexcept |
Returns limit - position. | |
constexpr self_t & | reserve (size_type new_capacity) |
Like std::vector::reserve(), increases this instance's capacity to new_capacity . | |
constexpr self_t & | resize (size_type new_size) |
Like std::vector::resize(size_type) | |
constexpr self_t & | resize (size_type new_size, const value_type &val) |
Like std::vector::resize(size_type, const value_type&) | |
constexpr self_t & | rewind () noexcept |
Sets position to zero. | |
constexpr void | setGrowthFactor (float v) noexcept |
Sets the growth factor when size() == capacity() is reached for growing operations, defaults to golden ratio DEFAULT_GROWTH_FACTOR. | |
self_t & | setLimit (size_type v) |
Sets new limit and adjusts position if new limit is below. | |
self_t & | setPosition (size_type v) |
Sets position. | |
constexpr bool | shared () const |
Returns true if growthFactor() < 0, otherwise false. | |
constexpr self_t & | shrink_to_fit () |
Like std::vector::shrink_to_fit(), but ensured constexpr . | |
constexpr size_type | size () const noexcept |
Like std::vector::size(). | |
self_t | slice () |
Returns a sliced duplicate starting from this buffers' current position. | |
self_t | slice (size_type idx, size_type length) |
Returns a sliced duplicate starting from the given idx . | |
constexpr void | swap (darray &x) noexcept |
Like std::vector::swap(). | |
std::string | toString () const noexcept |
const jau::type_info & | valueSignature () const noexcept |
Returns type signature of implementing class's stored value type. | |
![]() | |
static constexpr const float | DEFAULT_GROWTH_FACTOR = std::numbers::phi_v<float> |
Default growth factor using the golden ratio 1.618. | |
static constexpr const bool | uses_memmove = use_memmove |
static constexpr const bool | uses_realloc = use_memmove && std::is_base_of_v<jau::callocator<Value_type>, Alloc_type> |
static constexpr const bool | uses_secmem = use_secmem |
Extension to darray resulting in a sorted darray via insert().
In der hier deklarierten Template-Klasse 'darray_sorted' werden die einzelnen Listen Elemente sofort beim Einfuegen der Groesse nach sortiert ( In aufsteigender(UP)/absteigender(DOWN) Reihenfolge ). D.h. die Methode 'fuegeEin' fuegt die Listenelemente mittels Bisektionierung gleich sortiert ein.
fuegeEin liefert nun den Index zurueck, den das eingefuegte Element besitzt, ansonsten npos. die Listenelemente gleich sortiert eingefuegt werden, mittel Bisektionierung.
Neu ist die Methode findeElement, welche ebenfalls nach der MEthode der Bisektionierung arbeitet.
Value_type | |
Alloc_type | |
Size_type | |
use_memmove | |
use_secmem |
Definition at line 63 of file darray_sorted.hpp.
typedef darray<Value_type, Size_type, Alloc_type, use_memmove, use_secmem> jau::darray_sorted< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::darray_type |
Definition at line 65 of file darray_sorted.hpp.
enum jau::darray_sorted::order_t |
Enumerator | |
---|---|
UP | |
DOWN |
Definition at line 78 of file darray_sorted.hpp.
|
inline |
|
inline |
Definition at line 81 of file darray_sorted.hpp.
|
inline |
Definition at line 83 of file darray_sorted.hpp.
|
inline |
Definition at line 90 of file darray_sorted.hpp.
|
inlinenoexcept |
Definition at line 102 of file darray_sorted.hpp.
|
inline |
Returns index of given element if found or npos.
x |
Definition at line 111 of file darray_sorted.hpp.
|
inlineconstexpr |
Like std::vector::erase(), removes the elements at pos.
Updates end, limit and adjusts position if > > cpos
Definition at line 1318 of file darray.hpp.
|
inlineconstexpr |
Like std::vector::erase(), removes the elements in the range [first, last).
Updates end, limit and adjusts position if > cfirst.
Definition at line 1339 of file darray.hpp.
|
inlineconstexpr |
Similar to std::vector::erase() using an index, removes the elements at pos_idx.
Updates end, limit and adjusts position if > new limit.
Definition at line 1362 of file darray.hpp.
|
inlineconstexpr |
Similar to std::vector::erase() using indices, removes the elements in the range [first_idx, last_idx).
Updates end, limit and adjusts position if > new limit.
Definition at line 1373 of file darray.hpp.
|
inlinenoexcept |
Like std::vector::operator[](size_type), immutable reference.
Definition at line 1106 of file darray.hpp.
|
inlinenoexcept |
Like std::vector::operator[](size_type), mutable reference.
Definition at line 1113 of file darray.hpp.
|
inlineconstexprnoexcept |
Like std::vector::size().
Definition at line 1069 of file darray.hpp.
|
staticconstexpr |
Special value representing maximal value of size_type, used to denote an invalid index position return value, i.e.
no position
.
Definition at line 76 of file darray_sorted.hpp.