Qore Programming Language: safe_dslist< T > Class Template Reference

Qore Programming Language 0.8.11

- Main Page
- Related Pages
- Modules
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Public Member Functions | List of all members
safe_dslist< T > Class Template Reference

templated class for a double-ended singly-linked list that can be safely read from multiple threads without locking as long as writes are locked More...

## Public Member Functions
DLLLOCAL iterator | begin ()
| returns an iterator pointing to the first element of the list
DLLLOCAL const_iterator | begin () const
| returns an iterator pointing to the first element of the list
DLLLOCAL void | clear ()
| empties the list
DLLLOCAL bool | empty () const
| returns true if the list is empty
DLLLOCAL iterator | end ()
| returns an iterator pointing one element from the end of the list
DLLLOCAL const_iterator | end () const
| returns an iterator pointing one element from the end of the list
DLLLOCAL void | erase (iterator i)
| deletes the list element given by the iterator argument More...
DLLLOCAL void | erase_to_end (iterator i)
| deletes the list element after the iterator argument and all other elements to the end of the list More...
DLLLOCAL iterator | find (T data)
| returns an iterator either pointing to the element given if present in the list or pointing to one element from the end of the list if not
DLLLOCAL const_iterator | find (T data) const
| returns an iterator either pointing to the element given if present in the list or pointing to one element from the end of the list if not
DLLLOCAL iterator | last ()
| returns an iterator pointing to the last element in the list
DLLLOCAL const_iterator | last () const
| returns an iterator pointing to the last element in the list
DLLLOCAL bool | plural () const
| returns true if the list contains more than one element (constant time)
DLLLOCAL void | pop_front ()
| removes an element from the beginning of the list
DLLLOCAL void | populate (self_t &other)
| concatenates all elements of this list to the end of the list passed
DLLLOCAL void | populate (self_t *other)
| concatenates all elements of this list to the end of the list passed
DLLLOCAL void | push_back (T data)
| adds an element to the end of the list (constant time)
DLLLOCAL void | push_front (T data)
| adds an element to the beginning of the list (constant time)
DLLLOCAL bool | singular () const
| returns true if the list contains only one element (constant time)

## Detailed Description

### template<typename T>
class safe_dslist< T >

templated class for a double-ended singly-linked list that can be safely read from multiple threads without locking as long as writes are locked

Reading in multiple threads is safe as long as writes (appends at the end or beginning) are locked. Implements a singly-linked list with constant-time inserts at the beginning and end that can be read in a multi-threaded context without locking. Writes must be performed in a lock; however this class does not provide any locking; locking must be provided and performed externally to the class. Provides an STL-like interface.

## Member Function Documentation

template<typename T>

DLLLOCAL void safe_dslist< T >::erase | ( | iterator | i | ) |
| inline

deletes the list element given by the iterator argument

only constant time for the first element in the list, otherwise is O(n), linear with the length of the list

template<typename T>

DLLLOCAL void safe_dslist< T >::erase_to_end | ( | iterator | i | ) |
| inline

deletes the list element after the iterator argument and all other elements to the end of the list

O(n) where n=length of list after the element given

Note
  does not erase the element given by the iterator argument

The documentation for this class was generated from the following file:

- include/qore/safe_dslist (6585)