32#ifndef _QX_COLLECTION_H_
33#define _QX_COLLECTION_H_
48#pragma warning(disable:4996)
49#pragma warning(disable:4503)
52#include <QtCore/qmutex.h>
146template <
typename Key,
typename Value>
161 typedef typename type_list_pair_key_value::iterator
iterator;
164#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
194#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
212 bool insert(
const Key & key,
const Value & value);
213 bool insert(
long index,
const Key & key,
const Value & value);
216 bool replace(
long index,
const Key & key,
const Value & value);
217 bool swap(
long index1,
long index2);
218 bool move(
long indexFrom,
long indexTo);
235 template <
typename Compare>
244 template <
bool bIsPointer ,
int dummy>
273#include "../../inl/QxCollection/QxCollection.inl"
Common interface for all QxOrm containers qx::QxCollection<Key, Value>
foreach-style (based on BOOST_FOREACH macro) to iterate over all stl, boost and Qt containers + qx::Q...
Specialize hash_value function for some Qt and boost types (used for example by qx::QxCollection<Key,...
qx::IxCollection : common interface for all QxOrm containers qx::QxCollection<Key,...
qx::QxCollection<Key, Value> : QxOrm thread-safe container (keep insertion order + quick access by in...
const_iterator begin() const
Return a const STL-style iterator pointing to the first item in the list.
reverse_iterator rbegin()
Return a reverse STL-style iterator pointing to the first item in the list.
bool contains(const Key &key) const
Return 'true' if the list contains an occurrence of 'key', otherwise return 'false' (same as 'exist()...
void sortByValue(bool bAscending=true)
Sort all items in the list.
type_list_pair_key_value::const_iterator const_iterator
bool insert(const Key &key, const Value &value)
Add element 'value' at the end of the list indexed by 'key'.
QxCollection< Key, Value > & operator=(const QxCollection< Key, Value > &other)
Assign 'other' to this list and return a reference to this list.
const_reverse_iterator rbegin() const
Return a const reverse STL-style iterator pointing to the first item in the list.
reverse_iterator rend()
Return a reverse STL-style iterator pointing to the imaginary item after the last item in the list.
const_reference_key getKeyByIndex(long index) const
Return the key associated with the element at index position 'index'.
bool removeLast()
Remove the last item in the list.
bool move(long indexFrom, long indexTo)
Move the item at index position 'indexFrom' to index position 'indexTo'.
long size() const
Return the number of items in the list (same as 'count()')
QxCollection()
Construct an empty list.
const_reference_value getByKey(const Key &key) const
Return the item associated with the 'key'.
void updateHashPosition(long from=0, long to=-1, bool check=false)
void reserve(long size)
Request that the capacity of the allocated storage space for the items of the container be at least e...
void sortByKey(bool bAscending=true)
Sort all items in the list using associated keys to compare.
type_hash_position m_hash
Container for fast search by key.
virtual ~QxCollection()
Destroy the list.
const_reference_value getFirst() const
Return the first element in the list.
virtual qx::any _at(long index) const
void cloneCollection(QxCollection< Key, Value > *pClone, const QxCollection< Key, Value > &pRef)
bool insert(long index, const Key &key, const Value &value)
Insert element 'value' at position 'index' in the list indexed by 'key'.
bool replace(long index, const Key &key, const Value &value)
Replace the item at index position 'index' with element 'value' indexed by 'key'.
QPair< Key, Value > type_pair_key_value
const_reference_value getLast() const
Return the last element in the list.
bool removeByKey(const Key &key)
Remove the item indexed by 'key' in the list.
bool push_back(const Key &key, const Value &value)
Add element 'value' at the end of the list indexed by 'key'.
bool insert(long index, const QxCollection< Key, Value > &other)
Insert all items of 'other' at the end of the list.
type_list_pair_key_value::iterator iterator
const_iterator end() const
Return a const STL-style iterator pointing to the imaginary item after the last item in the list.
bool insert(const QxCollection< Key, Value > &other)
Add all items of 'other' at the end of the list.
long count() const
Return the number of items in the list (same as 'size()')
virtual bool _remove(long index)
iterator begin()
Return an STL-style iterator pointing to the first item in the list.
const_reverse_iterator rend() const
Return a const reverse STL-style iterator pointing to the imaginary item after the last item in the l...
virtual long _count() const
bool removeFirst()
Remove the first item in the list.
bool swap(long index1, long index2)
Exchange the item at index position 'index1' with the item at index position 'index2'.
void reverse()
Reverse all items in the list.
QxCollection(const QxCollection< Key, Value > &other)
Construct a copy of 'other'.
bool operator==(const QxCollection< Key, Value > &other) const
Return 'true' if 'other' is equal to this list, otherwise return 'false' (same values in the same ord...
QMutex m_mutex
Mutex => qx::QxCollection is thread-safe.
bool removeByIndex(long first, long last)
Remove all items from index position 'first' to index position 'last'.
void clear()
Remove all items from the list.
type_list_pair_key_value::const_reverse_iterator const_reverse_iterator
bool push_front(const Key &key, const Value &value)
Insert 'value' at the beginning of the list indexed by 'key'.
QHash< Key, long > type_hash_position
const Value & const_reference_value
QList< type_pair_key_value > type_list_pair_key_value
bool removeByIndex(long index)
Remove the item at index position 'index'.
bool isSameCollection(const QxCollection< Key, Value > *p1, const QxCollection< Key, Value > &p2) const
type_list_pair_key_value::reverse_iterator reverse_iterator
bool empty() const
Return 'true' if the list contains no items; otherwise return 'false'.
bool m_batch
Batch mode to sync internal containers.
const Key & const_reference_key
iterator end()
Return an STL-style iterator pointing to the imaginary item after the last item in the list.
type_list_pair_key_value m_list
Container to keep insertion order.
const_reference_value getByIndex(long index) const
Return the item at index position 'index'.
bool operator!=(const QxCollection< Key, Value > &other) const
Return 'true' if 'other' is not equal to this list, otherwise return 'false'.
bool exist(const Key &key) const
Return 'true' if the list contains an occurrence of 'key', otherwise return 'false' (same as 'contain...
qx::trait::get_class_name<T>::get() : return class name of type T under const char * format,...
#define QX_REGISTER_CLASS_NAME_TEMPLATE_2(className)
qx::trait::is_smart_ptr<T>::value : return true if T is a smart-pointer of boost, Qt or QxOrm librari...
Root namespace for all QxOrm library features.
static bool compareByKeyDescending(const type_pair_key_value &v1, const type_pair_key_value &v2)
static bool compareByValueDescending(const type_pair_key_value &v1, const type_pair_key_value &v2)
static bool compareByKeyAscending(const type_pair_key_value &v1, const type_pair_key_value &v2)
static bool compareByValueAscending(const type_pair_key_value &v1, const type_pair_key_value &v2)
static bool compareByValueAscending(const type_pair_key_value &v1, const type_pair_key_value &v2)
static bool compareByKeyAscending(const type_pair_key_value &v1, const type_pair_key_value &v2)
static bool compareByValueDescending(const type_pair_key_value &v1, const type_pair_key_value &v2)
static bool compareByKeyDescending(const type_pair_key_value &v1, const type_pair_key_value &v2)