00001 00002 #ifndef __SKYPE_INT_LIST_H 00003 #define __SKYPE_INT_LIST_H 00004 00005 #include "skype-string.h" 00006 #include <skype-thread.h> 00007 00008 /*! \class SEIntList skype-int-list.h "skype-int-list.h" 00009 * \brief SEIntList represents a list of integers. 00010 * 00011 * The operator [] is supported, which can be used to go through the list. 00012 */ 00013 class SEIntList 00014 { 00015 public: 00016 /** Creates an empty list of integers. */ 00017 SEIntList(); 00018 /** Constructs an implicitly shared copy of sl. */ 00019 SEIntList(const SEIntList& sl); 00020 /** Destroys the list and frees the data if this is the last reference to the list. */ 00021 ~SEIntList(); 00022 00023 /** \cond INTERNAL */ 00024 protected: 00025 class Element; 00026 class Data; 00027 Data* d; 00028 /** \endcond */ 00029 00030 public: 00031 /** Appends an integer at the end of the list. */ 00032 SEIntList& append(const int i); 00033 void push_back(const int& i) { 00034 append(i); 00035 } 00036 /** Removes the first element from the list and returns it. */ 00037 int peek(); 00038 /** Returns the size of the list. */ 00039 size_t size() const; 00040 00041 /** Returns the integer specified by its index. */ 00042 int & operator[](unsigned int index); 00043 int & operator[](unsigned int index) const { 00044 SEIntList* This = (SEIntList*) this; 00045 return This->SEIntList::operator [](index); 00046 } 00047 00048 /** Assigns a shallow copy of sl to this list and returns a reference to it. 00049 * This is very fast because the list isn't actually copied. 00050 */ 00051 SEIntList& operator=(const SEIntList& sl); 00052 /** Splits a string in a list of integer using the separaror sep. */ 00053 static SEIntList split(const SEString& str, char sep, char esc = '\\'); 00054 00055 bool contains(const int val); 00056 bool remove_val(const int val); 00057 bool remove_pos(const unsigned int pos); 00058 int find_pos(const int val); 00059 void resize(const unsigned int new_size); 00060 void clear(); 00061 00062 /** \cond INTERNAL */ 00063 protected: 00064 void init(); 00065 void d_ref(); 00066 void d_unref(); 00067 void detach(); 00068 /** \endcond */ 00069 }; 00070 00071 #endif // __SKYPE_INT_LIST_H
(c) Skype Technologies S.A. Confidential/Proprietary
Last updated: Fri Mar 16 2012