- Main Page
- Related Pages
- Classes
- Files
- Examples

- File List
- File Members

# skype-ptrint-dict.h

Go to the documentation of this file.

    00001
    00002 #ifndef __SKYPE_PTRINT_DICT_H
    00003 #define __SKYPE_PTRINT_DICT_H
    00004
    00005 #include <stddef.h>
    00006 #include <skype-thread.h>
    00007 #include <skype-int-list.h>
    00008
    00009 /** \class SEPtrIntDict skype-ptrint-dict.h "skype-ptrint-dict.h"
    00010  *  \brief SEPtrIntDict is a dictionary class of pointers associated to integers.
    00011  */
    00012 class SEPtrIntDict
    00013 {
    00014 public:
    00015         /** Creates an empty dictionary of pointers. */
    00016         SEPtrIntDict();
    00017         /** Constructs an implicitly shared copy of dict. */
    00018         SEPtrIntDict(const SEPtrIntDict& dict);
    00019         /** Destroys the dictionary and frees the data if this is the last reference to it. */
    00020         ~SEPtrIntDict();
    00021
    00022         /** \cond INTERNAL */
    00023 protected:
    00024         class Element;
    00025         class Data;
    00026         Data* d;
    00027         /** \endcond */
    00028
    00029 public:
    00030         /** Inserts the key with the value into the dictionary.
    00031          * Multiple items can have the same key, they are not overwritten.
    00032          * You can access them with the offset parameter of the find() function.
    00033          * If key is null, nothing is inserted.
    00034          */
    00035         void insert(const int key, const void* new_value);
    00036         /** Finds the specified key in the dictionary.
    00037          * \param key       Key to search.
    00038          * \param offset    When the dictionary contains several entries with the same key,
    00039          *                  use the offset param to indicate which key you want.
    00040          * \return null if the key is not found.
    00041          */
    00042         const void*& find(const int key, unsigned int offset = 0) const;
    00043         /** Assigns a shallow copy of dict to this dictionary and returns a reference to it.
    00044          * This is very fast because the dictionary isn't actually copied.
    00045          */
    00046         SEPtrIntDict& operator=(const SEPtrIntDict& dict);
    00047
    00048         /** Returns how many elements are in the dictionary. */
    00049         size_t size() const;
    00050
    00051         /** Use this function to iterate through the dictionary.
    00052          * It doesn't make sense to use this functions outside of an iteration (i.e. a loop).
    00053          * See also keyAt()
    00054          */
    00055         const void*& operator[](size_t i) const;
    00056         /** Use this function to iterate through the dictionary.
    00057          * It doesn't make sense to use this functions outside of an iteration (i.e. a loop).
    00058          * See also operator[]()
    00059          */
    00060         int keyAt(size_t i) const;
    00061
    00062         bool remove(const int key);
    00063
    00064         const void*& value(const int key) { return find(key); }
    00065
    00066         SEIntList keys();
    00067         /** \cond INTERNAL */
    00068
    00069 protected:
    00070         void d_ref();
    00071         void d_unref();
    00072         void detach();
    00073         /** \endcond */
    00074 };
    00075
    00076 #endif // __SKYPE_OBJ_DICT_H

All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

(c) Skype Technologies S.A. Confidential/Proprietary

Last updated: Fri Jan 27 2012