⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dict.h

📁 mgcp协议源代码。支持多种编码:g711
💻 H
📖 第 1 页 / 共 3 页
字号:
       collection must correctly implement the #PObject::Compare()#       function. The hash table is used to locate the entry.       @return       ordinal index position of the object, or P_MAX_INDEX.     */    virtual PINDEX GetValuesIndex(      const PObject & obj   /// Object to find equal value.    ) const;  //@}  private:    virtual PObject * RemoveAt(      PINDEX index   // Index position in collection to place the object.    );    /* This function is meaningless and will assert if executed.       @return       Always NULL.     */};#ifdef PHAS_TEMPLATES/**This template class maps the PAbstractSet to a specific object type. The   functions in this class primarily do all the appropriate casting of types.   By default, objects placed into the set will {\bf not} be deleted when   removed or when all references to the set are destroyed. This is different   from the default on most collection classes.   Note that if templates are not used the #PDECLARE_SET# macro will   simulate the template instantiation. */template <class T> class PSet : public PAbstractSet{  PCLASSINFO(PSet, PAbstractSet);  public:  /**@name Construction */  //@{    /**Create a new, empty, dictionary. The parameter indicates whether to       delete objects that are removed from the set.       Note that by default, objects placed into the set will {\bf not} be       deleted when removed or when all references to the set are destroyed.       This is different from the default on most collection classes.     */    inline PSet(BOOL initialDeleteObjects = FALSE)      : PAbstractSet() { AllowDeleteObjects(initialDeleteObjects); }  //@}  /**@name Overrides from class PObject */  //@{    /**Make a complete duplicate of the set. Note that all objects in the       array are also cloned, so this will make a complete copy of the set.     */    virtual PObject * Clone() const      { return PNEW PSet(0, this); }  //@}  /**@name New functions for class */  //@{    /**Include the spcified object into the set. If the objects value is       already in the set then the object is {\bf not} included. If the       AllowDeleteObjects option is set then the #obj# parameter is       also deleted.       The object values are compared, not the pointers.  So the objects in       the collection must correctly implement the #PObject::Compare()#       function. The hash table is used to locate the entry.     */    void Include(      const T * obj   // New object to include in the set.    ) { Append((PObject *)obj); }    /**Remove the object from the set. If the AllowDeleteObjects option is set       then the object is also deleted.       The object values are compared, not the pointers.  So the objects in       the collection must correctly implement the #PObject::Compare()#       function. The hash table is used to locate the entry.     */    void Exclude(      const T * obj   // New object to exclude in the set.    ) { Remove(obj); }    /**Determine if the value of the object is contained in the set. The       object values are compared, not the pointers.  So the objects in the       collection must correctly implement the #PObject::Compare()#       function. The hash table is used to locate the entry.       @return       TRUE if the object value is in the set.     */    BOOL operator[](      const T & key  /// Key to look for in the set.    ) { return AbstractContains(key); }    /**Determine if the value of the object is contained in the set. The       object values are compared, not the pointers.  So the objects in the       collection must correctly implement the #PObject::Compare()#       function. The hash table is used to locate the entry.       @return       TRUE if the object value is in the set.     */    BOOL Contains(      const T & key  /// Key to look for in the set.    ) { return AbstractContains(key); }    /**Get the key in the set at the ordinal index position.           The ordinal position in the set is determined by the hash values of the       keys and the order of insertion.       The last key/data pair is remembered by the class so that subseqent       access is very fast.       @return       reference to key at the index position.     */    virtual const T & GetKeyAt(      PINDEX index    /// Index of value to get.    ) const      { return (const T &)AbstractGetKeyAt(index); }  //@}  protected:    PSet(int dummy, const PSet * c)      : PAbstractSet(dummy, c)      { reference->deleteObjects = c->reference->deleteObjects; }};/**Declare set class.   This macro is used to declare a descendent of PAbstractSet class,   customised for a particular object type {\bf T}. This macro closes the   class declaration off so no additional members can be added.   If the compilation is using templates then this macro produces a typedef   of the #PSet# template class.   See the #PSet# class and #PDECLARE_SET# macro for more   information. */#define PSET(cls, T) typedef PSet<T> cls/**Begin declaration of a set class.   This macro is used to declare a descendent of PAbstractSet class,   customised for a particular object type {\bf T}.   If the compilation is using templates then this macro produces a descendent   of the #PSet# template class. If templates are not being used then the   macro defines a set of inline functions to do all casting of types. The   resultant classes have an identical set of functions in either case.   See the #PSet# and #PAbstractSet# classes for more information. */#define PDECLARE_SET(cls, T, initDelObj) \  PSET(cls##_PTemplate, T); \  PDECLARE_CLASS(cls, cls##_PTemplate) \  protected: \    cls(int dummy, const cls * c) \      : cls##_PTemplate(dummy, c) { } \  public: \    cls(BOOL initialDeleteObjects = initDelObj) \      : cls##_PTemplate(initialDeleteObjects) { } \    virtual PObject * Clone() const \      { return PNEW cls(0, this); } \#else // PHAS_TEMPLATES#define PSET(cls, K) \  class cls : public PAbstractSet { \  PCLASSINFO(cls, PAbstractSet); \  protected: \    inline cls(int dummy, const cls * c) \      : PAbstractSet(dummy, c) \      { reference->deleteObjects = c->reference->deleteObjects; } \  public: \    inline cls(BOOL initialDeleteObjects = FALSE) \      : PAbstractSet() { AllowDeleteObjects(initialDeleteObjects); } \    inline virtual PObject * Clone() const \      { return PNEW cls(0, this); } \    inline void Include(const PObject * key) \      { Append((PObject *)key); } \    inline void Exclude(const PObject * key) \      { Remove(key); } \    inline BOOL operator[](const K & key) \        { return AbstractContains(key); } \    inline BOOL Contains(const K & key) \        { return AbstractContains(key); } \    virtual const K & GetKeyAt(PINDEX index) const \      { return (const K &)AbstractGetKeyAt(index); } \  }#define PDECLARE_SET(cls, K, initDelObj) \ PSET(cls##_PTemplate, K); \ PDECLARE_CLASS(cls, cls##_PTemplate) \  protected: \    inline cls(int dummy, const cls * c) \      : cls##_PTemplate(dummy, c) { } \  public: \    inline cls(BOOL initialDeleteObjects = initDelObj) \      : cls##_PTemplate() { AllowDeleteObjects(initialDeleteObjects); } \    inline virtual PObject * Clone() const \      { return PNEW cls(0, this); } \#endif  // PHAS_TEMPLATES///////////////////////////////////////////////////////////////////////////////**An abstract dictionary container.*/class PAbstractDictionary : public PHashTable{  PCLASSINFO(PAbstractDictionary, PHashTable);  public:  /**@name Construction */  //@{    /**Create a new, empty, dictionary.       Note that by default, objects placed into the dictionary will be deleted       when removed or when all references to the dictionary are destroyed.     */    PINLINE PAbstractDictionary();  //@}  /**@name Overrides from class PObject */  //@{    /**Output the contents of the object to the stream. The exact output is       dependent on the exact semantics of the descendent class. This is       primarily used by the standard ##operator<<## function.       The default behaviour is to print the class name.     */    virtual void PrintOn(      ostream &strm   /// Stream to print the object into.    ) const;  //@}  /**@name Overrides from class PCollection */  //@{    /**Insert a new object into the dictionary. The semantics of this function       is different from that of the #PCollection# class. This function is       exactly equivalent to the SetAt() function that sets a data value at       the key value location.       @return       Always zero.     */    virtual PINDEX Insert(      const PObject & key,   /// Object value to use as the key.      PObject * obj          /// New object to place into the collection.    );    /**Insert a new object at the specified index. The index is converted to       a #POrdinalKey# type before being used in the #SetAt()#       function.       @return       #index# parameter.     */    virtual PINDEX InsertAt(      PINDEX index,   /// Index position in collection to place the object.      PObject * obj   /// New object to place into the collection.    );    /**Remove an object at the specified index. The index is converted to       a #POrdinalKey# type before being used in the #GetAt()#       function. The returned pointer is then removed using the #SetAt()#       function to set that key value to NULL. If the       #AllowDeleteObjects# option is set then the object is also       deleted.       @return       pointer to the object being removed, or NULL if it was deleted.     */    virtual PObject * RemoveAt(      PINDEX index   /// Index position in collection to place the object.    );    /**Set the object at the specified index to the new value. The index is       converted to a #POrdinalKey# type before being used.This will       overwrite the existing entry. If the AllowDeleteObjects option is set       then the old object is also deleted.       @return       TRUE if the object was successfully added.     */    virtual BOOL SetAt(      PINDEX index,   /// Index position in collection to set.      PObject * val   /// New value to place into the collection.    );    /**Get the object at the specified index position. The index is converted       to a #POrdinalKey# type before being used. If the index was not in       the collection then NULL is returned.       @return       pointer to object at the specified index.     */    virtual PObject * GetAt(      PINDEX index  /// Index position in the collection of the object.    ) const;    /**Search the collection for the specific instance of the object. The       object pointers are compared, not the values. The hash table is used       to locate the entry.       Note that that will require value comparisons to be made to find the       equivalent entry and then a final check is made with the pointers to       see if they are the same instance.       @return       ordinal index position of the object, or P_MAX_INDEX.     */    virtual PINDEX GetObjectsIndex(      const PObject * obj  /// Object to find.    ) const;    /**Search the collection for the specified value of the object. The object       values are compared, not the pointers.  So the objects in the       collection must correctly implement the #PObject::Compare()#       function. The hash table is used to locate the entry.       @return       ordinal index position of the object, or P_MAX_INDEX.     */    virtual PINDEX GetValuesIndex(      const PObject & obj  /// Object to find value of.    ) const;  //@}  /**@name New functions for class */  //@{    /**Set the data at the specified ordinal index position in the dictionary.       The ordinal position in the dictionary is determined by the hash values       of the keys and the order of insertion.       @return       TRUE if the new object could be placed into the dictionary.     */    virtual BOOL SetDataAt(      PINDEX index,   /// Ordinal index in the dictionary.      PObject * obj   /// New object to put into the dictionary.    );    /**Add a new object to the collection. If the objects value is already in       the dictionary then the object is overrides the previous value. If the       AllowDeleteObjects option is set then the old object is also deleted.       The object is placed in the an ordinal position dependent on the keys       hash function. Subsequent searches use the has function to speed access       to the data item.       @return       TRUE if the object was successfully added.     */    virtual BOOL AbstractSetAt(      const PObject & key,  /// Key for position in dictionary to add object.      PObject * obj         /// New object to put into the dictionary.    );    /**Get the object at the specified key position. If the key was not in the       collection then this function asserts.       This function is primarily for use by the #operator[]# function is       descendent template classes.       @return       reference to object at the specified key.     */    virtual PObject & GetRefAt(      const PObject & key   /// Key for position in dictionary to get object.    ) const;    /**Get the object at the specified key position. If the key was not in the       collection then NULL is returned.       @return       pointer to object at the specified key.     */    virtual PObject * AbstractGetAt(      const PObject & key   /// Key for position in dictionary to get object.    ) const;  //@}  protected:    PINLINE PAbstractDictionary(int dummy, const PAbstractDictionary * c);  private:    virtual PINDEX Append(      PObject * obj   // New object to place into the collection.    );    /* This function is meaningless and will assert.       @return       Always zero.     */    virtual BOOL Remove(      const PObject * obj   // Existing object to remove from the collection.    );    /* Remove the object from the collection. If the AllowDeleteObjects option       is set then the object is also deleted.       Note that the comparison for searching for the object in collection is       made by pointer, not by value. Thus the parameter must point to the       same instance of the object that is in the collection.       @return       TRUE if the object was in the collection.     */};#ifdef PHAS_TEMPLATES/**This template class maps the PAbstractDictionary to a specific key and data   types. The functions in this class primarily do all the appropriate casting   of types.   Note that if templates are not used the #PDECLARE_DICTIONARY# macro   will simulate the template instantiation. */template <class K, class D> class PDictionary : public PAbstractDictionary{  PCLASSINFO(PDictionary, PAbstractDictionary);  public:  /**@name Construction */  //@{    /**Create a new, empty, dictionary.       Note that by default, objects placed into the dictionary will be       deleted when removed or when all references to the dictionary are

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -