diff options
author | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2009-12-10 14:38:17 (GMT) |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2009-12-10 15:08:02 (GMT) |
commit | b6352d487491e4d25db8a008de75280a666b0fce (patch) | |
tree | a6704970d5c472468724b38cdad4360cdc1f123c /src/corelib/tools/qmap.h | |
parent | 46e080ba1b0b7fdb67eda60002991f6b20e0f0ab (diff) | |
download | Qt-b6352d487491e4d25db8a008de75280a666b0fce.zip Qt-b6352d487491e4d25db8a008de75280a666b0fce.tar.gz Qt-b6352d487491e4d25db8a008de75280a666b0fce.tar.bz2 |
add {QString,QByteArray,QList,QLinkedList,QHash,QMap,QVector}::isSharedWith()
these functions just compare the d pointers of two objects. this can be
used to verify the validity of cached data: you keep a copy of the
original data in your cache. consequently, any changes to the original
data must detach, so this function reflects whether the cached data is
still up-to-date.
of course, this is not thread safe, as the data might change right after
you check it, but that's a general problem of cache coherency which
needs to be handled further up the stack.
the functions are internal because the other detaching-related functions
are internal as well for reasons beyond me.
Reviewed-by: brad
Diffstat (limited to 'src/corelib/tools/qmap.h')
-rw-r--r-- | src/corelib/tools/qmap.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h index 0441107..ce97178 100644 --- a/src/corelib/tools/qmap.h +++ b/src/corelib/tools/qmap.h @@ -182,6 +182,7 @@ public: inline void detach() { if (d->ref != 1) detach_helper(); } inline bool isDetached() const { return d->ref == 1; } inline void setSharable(bool sharable) { if (!sharable) detach(); d->sharable = sharable; } + inline bool isSharedWith(const QMap<Key, T> &other) const { return d == other.d; } inline void setInsertInOrder(bool ordered) { d->insertInOrder = ordered; } void clear(); |