home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 March / macformat-022.iso / Shareware City / Developers / src / out-of-phase-102-c / OutOfPhase 1.02 Source / OutOfPhase Folder / Level 0 Macintosh 29Sep94 / Array.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-23  |  1.9 KB  |  57 lines  |  [TEXT/KAHL]

  1. /* Array.h */
  2.  
  3. #ifndef Included_Array_h
  4. #define Included_Array_h
  5.  
  6. /* Array depends on */
  7. /* MiscInfo.h */
  8. /* Audit */
  9. /* Debug */
  10. /* Definitions */
  11. /* Memory */
  12.  
  13. /* Abstract data structure for maintaining a linear array of elements.  It provides */
  14. /* indexed lookup, insertion, and deletion capabilities on the array, and attempts */
  15. /* to provide reasonably efficient storage management */
  16.  
  17. struct ArrayRec;
  18. typedef struct ArrayRec ArrayRec;
  19.  
  20. /* create a new array.  returns NIL if it couldn't allocate any memory. */
  21. ArrayRec*            NewArray(void);
  22.  
  23. /* create a new array with preallocated space for a bunch of elements. */
  24. ArrayRec*            NewArrayReserveSpace(long NumElements);
  25.  
  26. /* dispose of an array.  any pointers contained in the array are NOT disposed. */
  27. void                    DisposeArray(ArrayRec* Array);
  28.  
  29. /* get the number of elements currently stored in the array */
  30. long                    ArrayGetLength(ArrayRec* Array);
  31.  
  32. /* get an indexed element from the array */
  33. void*                    ArrayGetElement(ArrayRec* Array, long Where);
  34.  
  35. /* change the value of an indexed element in the array */
  36. void                    ArraySetElement(ArrayRec* Array, void* Element, long Where);
  37.  
  38. /* insert an element into the array.  Where is the index of the element to insert */
  39. /* BEFORE.  if Where == number of elements in the array, the element is appended. */
  40. /* return True if successful */
  41. MyBoolean            ArrayInsertElement(ArrayRec* Array, void* Element, long Where);
  42.  
  43. /* append an element to the end of the array.  returns True if successful */
  44. MyBoolean            ArrayAppendElement(ArrayRec* Array, void* Element);
  45.  
  46. /* delete an element from the array and shift any elements after it down one. */
  47. void                    ArrayDeleteElement(ArrayRec* Array, long Where);
  48.  
  49. /* search the array to find the position of the specified element.  if the */
  50. /* element can't be found in the array, it returns -1. */
  51. long                    ArrayFindElement(ArrayRec* Array, void* Element);
  52.  
  53. /* return a duplicate of the array */
  54. ArrayRec*            DuplicateArray(ArrayRec* Original);
  55.  
  56. #endif
  57.