HashTable.h
上传用户:shenzhenrh
上传日期:2013-05-12
资源大小:2904k
文件大小:3k
源码类别:

信息检索与抽取

开发平台:

Unix_Linux

  1. /* Interface for Objective C NeXT-compatible HashTable object
  2.    Copyright (C) 1993 Free Software Foundation, Inc.
  3.    Written by:  R. Andrew McCallum <mccallum@cs.rochester.edu>
  4.    Dept. of Computer Science, U. of Rochester, Rochester, NY  14627
  5.    This library is free software; you can redistribute it and/or
  6.    modify it under the terms of the GNU Library General Public
  7.    License as published by the Free Software Foundation; either
  8.    version 2 of the License, or (at your option) any later version.
  9.    
  10.    This library is distributed in the hope that it will be useful,
  11.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.    Library General Public License for more details.
  14.    You should have received a copy of the GNU Library General Public
  15.    License along with this library; if not, write to the Free
  16.    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. */ 
  18. /******************************************************************
  19.   TODO:
  20.    Does not implement methods for archiving itself.
  21.    Does not implement -freeKeys:values:.
  22. ******************************************************************/
  23. #ifndef __HashTable_h_INCLUDE_GNU
  24. #define __HashTable_h_INCLUDE_GNU
  25. //#include <coll/objc-gnu2next.h>
  26. #include <objc/Object.h>
  27. #include <objc/hash.h>
  28. typedef node_ptr GNUHashState;
  29. @interface HashTable: Object
  30. {
  31.     unsigned    count;          /* Current number of associations */
  32.     const char  *keyDesc;       /* Description of keys */
  33.     const char  *valueDesc;     /* Description of values */
  34.     unsigned    _nbBuckets;     /* Current size of the array */
  35.     cache_ptr   _buckets;       /* Data array */
  36. }
  37. /* We include some instance vars we don't need so we are compatible
  38.    with NeXT programs that expect them to be there */
  39. /* Initializing */
  40. - init;
  41. - initKeyDesc: (const char *)aKeyDesc;
  42. - initKeyDesc:(const char *)aKeyDesc 
  43.     valueDesc:(const char *)aValueDesc;
  44. - initKeyDesc: (const char *) aKeyDesc 
  45.     valueDesc: (const char *)aValueDesc 
  46.     capacity: (unsigned) aCapacity;
  47. /* Freeing */
  48. - free;
  49. - freeObjects;
  50. - freeKeys:(void (*) (void *))keyFunc 
  51.     values:(void (*) (void *))valueFunc;
  52. - empty;
  53. /* Copying */
  54. - shallowCopy;
  55. - deepen;
  56.   
  57. /* Manipulating */
  58. - (unsigned)count;
  59. - (BOOL)isKey:(const void *)aKey;
  60. - (void *)valueForKey:(const void *)aKey;
  61. - (void *)insertKey:(const void *)aKey value:(void *)aValue;
  62. - (void *)removeKey:(const void *)aKey;
  63. /* Iterating */
  64. - (GNUHashState)initState;
  65. - (BOOL)nextState:(GNUHashState *)aState 
  66.     key:(const void **)aKey 
  67.     value:(void **)aValue;
  68. /* Archiving */
  69. - read: (TypedStream*)aStream;
  70. - write: (TypedStream*)aStream;
  71. /* Old-style creation */
  72. + newKeyDesc: (const char *)aKeyDesc;
  73. + newKeyDesc:(const char *)aKeyDesc 
  74.     valueDesc:(const char *)aValueDesc;
  75. + newKeyDesc:(const char *)aKeyDesc 
  76.     valueDesc:(const char *)aValueDesc
  77.     capacity:(unsigned)aCapacity;
  78. /* Sending messages to elements of the hashtable */
  79. - makeObjectsPerform:(SEL)aSel;
  80. - makeObjectsPerform:(SEL)aSel with:anObject;
  81. @end
  82. #endif /* __HashTable_h_INCLUDE_GNU */