|
HikoGUI
A low latency retained GUI
|
#include <hikogui/gap_buffer.hpp>
Data Structures | |
| class | const_iterator |
| class | iterator |
Public Types | |
| using | value_type = T |
| using | allocator_type = Allocator |
| using | size_type = std::size_t |
| using | difference_type = ptrdiff_t |
| using | reference = T& |
| using | const_reference = T const& |
| using | pointer = T * |
| using | const_pointer = T const * |
Public Member Functions | |
| constexpr | gap_buffer (allocator_type const &allocator=allocator_type{}) noexcept |
| Construct an empty buffer. | |
| constexpr | gap_buffer (std::initializer_list< T > init, allocator_type const &allocator=allocator_type{}) |
| Construct a buffer with the given initializer list. | |
| constexpr | gap_buffer (gap_buffer const &other) noexcept |
| Copy constructor. | |
| constexpr gap_buffer & | operator= (gap_buffer const &other) noexcept |
| Copy assignment. | |
| constexpr | gap_buffer (gap_buffer &&other) noexcept |
| Move constructor. | |
| constexpr gap_buffer & | operator= (gap_buffer &&other) noexcept |
| Move assignment operator. | |
| constexpr | ~gap_buffer () |
| Destructor. | |
| constexpr reference | operator[] (size_type index) noexcept |
| Index operator. | |
| constexpr const_reference | operator[] (size_type index) const noexcept |
| Index operator. | |
| constexpr reference | at (size_type index) |
| Get item to reference at. | |
| constexpr const_reference | at (size_type index) const |
| Get item to reference at. | |
| constexpr reference | front () noexcept |
| constexpr const_reference | front () const noexcept |
| constexpr reference | back () noexcept |
| constexpr const_reference | back () const noexcept |
| constexpr void | pop_back () noexcept |
| constexpr void | pop_front () noexcept |
| constexpr void | clear () noexcept |
| Clears the buffer. | |
| constexpr std::size_t | size () const noexcept |
| constexpr bool | empty () const noexcept |
| constexpr std::size_t | capacity () const noexcept |
| constexpr void | reserve (std::size_t new_capacity) noexcept |
| constexpr iterator | begin () noexcept |
| constexpr const_iterator | begin () const noexcept |
| constexpr const_iterator | cbegin () const noexcept |
| constexpr iterator | end () noexcept |
| constexpr const_iterator | end () const noexcept |
| constexpr const_iterator | cend () const noexcept |
| template<typename... Args> | |
| constexpr reference | emplace_back (Args &&...args) noexcept |
| constexpr void | push_back (value_type const &value) noexcept |
| constexpr void | push_back (value_type &&value) noexcept |
| template<typename... Args> | |
| constexpr reference | emplace_front (Args &&...args) noexcept |
| constexpr void | push_front (value_type const &value) noexcept |
| constexpr void | push_front (value_type &&value) noexcept |
| template<typename... Args> | |
| constexpr reference | emplace_before (const_iterator position, Args &&...args) noexcept |
| Place the gap at the position and emplace at the end of the gap. | |
| constexpr iterator | insert_before (const_iterator position, value_type const &value) noexcept |
| Place the gap at the position and emplace at the end of the gap. | |
| constexpr iterator | insert_before (const_iterator position, value_type &&value) noexcept |
| Place the gap at the position and emplace at the end of the gap. | |
| template<typename It > | |
| constexpr iterator | insert_before (const_iterator position, It first, It last) noexcept |
| Insert items If an insert requires a reallocation then all current iterators become invalid. | |
| template<typename... Args> | |
| constexpr reference | emplace_after (const_iterator position, Args &&...args) noexcept |
| Place the gap at the position and emplace at the beginning of the gap. | |
| constexpr iterator | insert_after (const_iterator position, value_type const &value) noexcept |
| Place the gap at the position and emplace at the beginning of the gap. | |
| constexpr iterator | insert_after (const_iterator position, value_type &&value) noexcept |
| Place the gap at the position and emplace at the beginning of the gap. | |
| template<typename It > | |
| constexpr iterator | insert_after (const_iterator position, It first, It last) noexcept |
| Insert items. | |
| constexpr iterator | erase (const_iterator first, const_iterator last) noexcept |
| Erase items. | |
| constexpr iterator | erase (const_iterator position) noexcept |
| Erase item. | |
Friends | |
| constexpr friend iterator | begin (gap_buffer &rhs) noexcept |
| constexpr friend const_iterator | begin (gap_buffer const &rhs) noexcept |
| constexpr friend const_iterator | cbegin (gap_buffer const &rhs) noexcept |
| constexpr friend iterator | end (gap_buffer &rhs) noexcept |
| constexpr friend const_iterator | end (gap_buffer const &rhs) noexcept |
| constexpr friend const_iterator | cend (gap_buffer const &rhs) noexcept |
| constexpr friend bool | operator== (gap_buffer const &lhs, gap_buffer const &rhs) noexcept |
| template<typename Container > | |
| constexpr friend bool | operator== (gap_buffer const &lhs, Container const &rhs) noexcept |
| template<typename Container > | |
| constexpr friend bool | operator== (Container const &lhs, gap_buffer const &rhs) noexcept |
Gap Buffer This container is similar to a std::vector, optimized for repeated insertions and deletion at the same position.
This container is especially useful for text editing where inserts and deletes are happening at a cursor.
Like a std::vector a gap_buffer has extra capacity to do insertion without needing to reallocate, however this capacity can be located anywhere in the allocated memory in a single continues region called the gap.
When inserting/deleting data in the gap_buffer the gap will move to this location.
|
inlineconstexprnoexcept |
Construct an empty buffer.
|
inlineconstexpr |
Construct a buffer with the given initializer list.
|
inlineconstexprnoexcept |
Copy constructor.
Allocates memory and copies all items from other into this.
|
inlineconstexprnoexcept |
Move constructor.
This constructor will move the allocation of the other gap_buffer.
|
inlineconstexpr |
Destructor.
Destroys all items and deallocates the buffer.
|
inlineconstexpr |
Get item to reference at.
| std::out_of_range | Thrown when index is out of range. |
| index | The index in the buffer. |
|
inlineconstexpr |
Get item to reference at.
| std::out_of_range | Thrown when index is out of range. |
| index | The index in the buffer. |
|
inlineconstexprnoexcept |
Clears the buffer.
Destroys all items in the buffer. This function will keep the memory allocated.
After this object was move() this function will allow the object to be reused.
|
inlineconstexprnoexcept |
Place the gap at the position and emplace at the beginning of the gap.
If an insert requires a reallocation (size() == capacity()) then all current iterators become invalid.
|
inlineconstexprnoexcept |
Place the gap at the position and emplace at the end of the gap.
If an insert requires a reallocation (size() == capacity()) then all current iterators become invalid.
|
inlineconstexprnoexcept |
Erase items.
| first | Location of first item to remove. |
| last | Location beyond last item to remove. |
|
inlineconstexprnoexcept |
Erase item.
| position | Location of item to remove |
|
inlineconstexprnoexcept |
Insert items.
| position | Location to insert at. |
| first | The first item to insert. |
| last | The one beyond last item to insert. |
|
inlineconstexprnoexcept |
Place the gap at the position and emplace at the beginning of the gap.
If an insert requires a reallocation (size() == capacity()) then all current iterators become invalid.
|
inlineconstexprnoexcept |
Place the gap at the position and emplace at the beginning of the gap.
If an insert requires a reallocation (size() == capacity()) then all current iterators become invalid.
|
inlineconstexprnoexcept |
Insert items If an insert requires a reallocation then all current iterators become invalid.
| position | Location to insert before. |
| first | The first item to insert. |
| last | The one beyond last item to insert. |
|
inlineconstexprnoexcept |
Place the gap at the position and emplace at the end of the gap.
If an insert requires a reallocation (size() == capacity()) then all current iterators become invalid.
|
inlineconstexprnoexcept |
Place the gap at the position and emplace at the end of the gap.
If an insert requires a reallocation (size() == capacity()) then all current iterators become invalid.
|
inlineconstexprnoexcept |
Move assignment operator.
This functional will allocate its own buffer and move the items from other.
|
inlineconstexprnoexcept |
Copy assignment.
This copies the items from the other buffer to this buffer. This may reuse allocation of this buffer if it was allocated before.
Complexity is linear with the number of items in other.
|
inlineconstexprnoexcept |
Index operator.
Return a reference to the ittem at index.
| index | The index in the buffer. |
|
inlineconstexprnoexcept |
Index operator.
Return a reference to the item at index.
| index | The index in the buffer. |