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