Krita Source Code Documentation
Loading...
Searching...
No Matches
KisHistoryList< T > Class Template Reference

#include <KisHistoryList.h>

Public Types

using const_iterator = typename std::deque<T>::const_iterator
 

Public Member Functions

int append (const T &value)
 
at (int pos) const
 
const_iterator cbegin () const
 
const_iterator cend () const
 
void clear ()
 
 KisHistoryList (int size)
 
int maxSize () const
 
int size () const
 

Private Attributes

int m_maxSize = 0
 
std::deque< T > m_values
 

Detailed Description

template<typename T>
class KisHistoryList< T >

Definition at line 15 of file KisHistoryList.h.

Member Typedef Documentation

◆ const_iterator

template<typename T >
using KisHistoryList< T >::const_iterator = typename std::deque<T>::const_iterator

Definition at line 18 of file KisHistoryList.h.

Constructor & Destructor Documentation

◆ KisHistoryList()

template<typename T >
KisHistoryList< T >::KisHistoryList ( int size)
inline

Definition at line 21 of file KisHistoryList.h.

23 {
24 }
int size() const

Member Function Documentation

◆ append()

template<typename T >
int KisHistoryList< T >::append ( const T & value)
inline

Add an element to the history list

If an element already exists in the list, then this existing element is put into the top of the list (as recently used).

If the number of elements exceeds the maxSize() value, the oldest element of the history list is removed.

Definition at line 53 of file KisHistoryList.h.

53 {
54 auto it = std::find(m_values.begin(), m_values.end(), value);
55
56 if (it != m_values.end()) {
57 std::rotate(m_values.begin(), it, std::next(it));
58 } else {
59 m_values.push_front(value);
60 if (int(m_values.size()) > m_maxSize) {
61 m_values.pop_back();
62 }
63 }
64
65 // return the index of just added color (always 0)
66 return 0;
67 }
float value(const T *src, size_t ch)
std::deque< T > m_values

References KisHistoryList< T >::m_maxSize, KisHistoryList< T >::m_values, and value().

◆ at()

template<typename T >
T KisHistoryList< T >::at ( int pos) const
inline
Returns
@pos's element of the history list

Definition at line 36 of file KisHistoryList.h.

36 {
39
40 return m_values.at(pos);
41 }
#define KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(cond, val)
Definition kis_assert.h:129

References KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE, KisHistoryList< T >::m_values, and KisHistoryList< T >::size().

◆ cbegin()

template<typename T >
const_iterator KisHistoryList< T >::cbegin ( ) const
inline

Definition at line 83 of file KisHistoryList.h.

83 {
84 return m_values.cbegin();
85 }

References KisHistoryList< T >::m_values.

◆ cend()

template<typename T >
const_iterator KisHistoryList< T >::cend ( ) const
inline

Definition at line 87 of file KisHistoryList.h.

87 {
88 return m_values.cend();
89 }

References KisHistoryList< T >::m_values.

◆ clear()

template<typename T >
void KisHistoryList< T >::clear ( )
inline

Clear all historical elements from the list

Definition at line 72 of file KisHistoryList.h.

72 {
73 m_values.clear();
74 }

References KisHistoryList< T >::m_values.

◆ maxSize()

template<typename T >
int KisHistoryList< T >::maxSize ( ) const
inline
Returns
the maximum possible number of elements in the list

Definition at line 79 of file KisHistoryList.h.

79 {
80 return m_maxSize;
81 }

References KisHistoryList< T >::m_maxSize.

◆ size()

template<typename T >
int KisHistoryList< T >::size ( ) const
inline
Returns
the number of elements in the list

Definition at line 29 of file KisHistoryList.h.

29 {
30 return m_values.size();
31 }

References KisHistoryList< T >::m_values.

Member Data Documentation

◆ m_maxSize

template<typename T >
int KisHistoryList< T >::m_maxSize = 0
private

Definition at line 93 of file KisHistoryList.h.

◆ m_values

template<typename T >
std::deque<T> KisHistoryList< T >::m_values
private

Definition at line 94 of file KisHistoryList.h.


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