|
HikoGUI
A low latency retained GUI
|
#include <hikogui/gap_buffer.hpp>
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 * |
| using | iterator = gap_buffer_iterator<T> |
| using | const_iterator = gap_buffer_iterator<T const> |
Public Member Functions | |
| gap_buffer (allocator_type const &allocator=allocator_type{}) noexcept | |
| Construct an empty buffer. | |
| gap_buffer (std::initializer_list< T > init, allocator_type const &allocator=allocator_type{}) | |
| Construct a buffer with the given initializer list. | |
| gap_buffer (gap_buffer const &other) noexcept | |
| Copy constructor. | |
| gap_buffer & | operator= (gap_buffer const &other) noexcept |
| Copy assignment. | |
| gap_buffer (gap_buffer &&other) noexcept | |
| Move constructor. | |
| gap_buffer & | operator= (gap_buffer &&other) noexcept |
| Move assignment operator. | |
| ~gap_buffer () | |
| Destructor. | |
| reference | operator[] (size_type index) noexcept |
| Index operator. | |
| const_reference | operator[] (size_type index) const noexcept |
| Index operator. | |
| reference | at (size_type index) |
| Get item to reference at. | |
| const_reference | at (size_type index) const |
| Get item to reference at. | |
| reference | front () noexcept |
| const_reference | front () const noexcept |
| reference | back () noexcept |
| const_reference | back () const noexcept |
| void | pop_back () noexcept |
| void | pop_front () noexcept |
| void | clear () noexcept |
| Clears the buffer. | |
| std::size_t | size () const noexcept |
| bool | empty () const noexcept |
| std::size_t | capacity () const noexcept |
| void | reserve (std::size_t new_capacity) noexcept |
| iterator | begin () noexcept |
| const_iterator | begin () const noexcept |
| const_iterator | cbegin () const noexcept |
| iterator | end () noexcept |
| const_iterator | end () const noexcept |
| const_iterator | cend () const noexcept |
| template<typename... Args> | |
| reference | emplace_back (Args &&...args) noexcept |
| void | push_back (value_type const &value) noexcept |
| void | push_back (value_type &&value) noexcept |
| template<typename... Args> | |
| reference | emplace_front (Args &&...args) noexcept |
| void | push_front (value_type const &value) noexcept |
| void | push_front (value_type &&value) noexcept |
| template<typename... Args> | |
| reference | emplace_before (const_iterator position, Args &&...args) noexcept |
| Place the gap at the position and emplace at the end of the gap. | |
| 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. | |
| 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 > | |
| 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> | |
| reference | emplace_after (const_iterator position, Args &&...args) noexcept |
| Place the gap at the position and emplace at the beginning of the gap. | |
| 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. | |
| 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 > | |
| iterator | insert_after (const_iterator position, It first, It last) noexcept |
| Insert items. | |
| iterator | erase (const_iterator first, const_iterator last) noexcept |
| Erase items. | |
| iterator | erase (const_iterator position) noexcept |
| Erase item. | |
Friends | |
| template<typename IT > | |
| class | gap_buffer_iterator |
| iterator | begin (gap_buffer &rhs) noexcept |
| const_iterator | begin (gap_buffer const &rhs) noexcept |
| const_iterator | cbegin (gap_buffer const &rhs) noexcept |
| iterator | end (gap_buffer &rhs) noexcept |
| const_iterator | end (gap_buffer const &rhs) noexcept |
| const_iterator | cend (gap_buffer const &rhs) noexcept |
| bool | operator== (gap_buffer const &lhs, gap_buffer const &rhs) noexcept |
| template<typename Container > | |
| bool | operator== (gap_buffer const &lhs, Container const &rhs) noexcept |
| template<typename Container > | |
| 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.
|
inlinenoexcept |
Construct an empty buffer.
|
inline |
Construct a buffer with the given initializer list.
|
inlinenoexcept |
Copy constructor.
Allocates memory and copies all items from other into this.
|
inlinenoexcept |
Move constructor.
This constructor will move the allocation of the other gap_buffer.
|
inline |
Destructor.
Destroys all items and deallocates the buffer.
|
inline |
Get item to reference at.
| std::out_of_range | Thrown when index is out of range. |
| index | The index in the buffer. |
|
inline |
Get item to reference at.
| std::out_of_range | Thrown when index is out of range. |
| index | The index in the buffer. |
|
inlinenoexcept |
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.
|
inlinenoexcept |
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.
|
inlinenoexcept |
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.
|
inlinenoexcept |
Erase items.
| first | Location of first item to remove. |
| last | Location beyond last item to remove. |
|
inlinenoexcept |
Erase item.
| position | Location of item to remove |
|
inlinenoexcept |
Insert items.
| position | Location to insert at. |
| first | The first item to insert. |
| last | The one beyond last item to insert. |
|
inlinenoexcept |
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.
|
inlinenoexcept |
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.
|
inlinenoexcept |
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. |
|
inlinenoexcept |
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.
|
inlinenoexcept |
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.
|
inlinenoexcept |
Move assignment operator.
This functional will allocate its own buffer and move the items from other.
|
inlinenoexcept |
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.
|
inlinenoexcept |
Index operator.
Return a reference to the ittem at index.
| index | The index in the buffer. |
|
inlinenoexcept |
Index operator.
Return a reference to the item at index.
| index | The index in the buffer. |