home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_HDF.idb / usr / freeware / include / hdf / dynarray.h.z / dynarray.h
Encoding:
C/C++ Source or Header  |  1999-01-26  |  5.7 KB  |  157 lines

  1. /****************************************************************************
  2.  * NCSA HDF                                                                 *
  3.  * Software Development Group                                               *
  4.  * National Center for Supercomputing Applications                          *
  5.  * University of Illinois at Urbana-Champaign                               *
  6.  * 605 E. Springfield, Champaign IL 61820                                   *
  7.  *                                                                          *
  8.  * For conditions of distribution and use, see the accompanying             *
  9.  * hdf/COPYING file.                                                        *
  10.  *                                                                          *
  11.  ****************************************************************************/
  12.  
  13. /* $Id: dynarray.h,v 1.1 1996/01/19 01:13:40 koziol Exp $ */
  14.  
  15. /*-----------------------------------------------------------------------------
  16.  * File:    dynarray.h
  17.  * Purpose: header file for dynamic array API
  18.  * Dependencies: 
  19.  * Invokes:
  20.  * Contents:
  21.  * Structure definitions: 
  22.  * Constant definitions: 
  23.  *---------------------------------------------------------------------------*/
  24.  
  25. /* avoid re-inclusion */
  26. #ifndef __DYNARRAY_H
  27. #define __DYNARRAY_H
  28.  
  29. #include "hdf.h"
  30.  
  31. /*
  32.     Define the pointer to the dynarray without giving outside routines access
  33.     to the internal workings of the structure.
  34. */
  35. typedef struct dynarray_tag *dynarr_p;
  36.  
  37. #if defined DYNARRAY_MASTER | defined DYNARRAY_TESTER
  38. typedef struct dynarray_tag 
  39.   {
  40.       intn num_elems;       /* Number of elements in the array currently */
  41.       intn incr_mult;       /* Multiple to increment the array size by */
  42.       VOIDP *arr;           /* Pointer to the actual array of void *'s */
  43.   }dynarr_t;
  44.  
  45. #endif /* DYNARRAY_MASTER | DYNARRAY_TESTER */
  46.  
  47. #if defined c_plusplus || defined __cplusplus
  48. extern      "C"
  49. {
  50. #endif                          /* c_plusplus || __cplusplus */
  51.  
  52. /******************************************************************************
  53.  NAME
  54.      DAcreate_array - Create a dynarray
  55.  
  56.  DESCRIPTION
  57.     Create a dynarray for later use.  This routine allocates the dynarray
  58.     structure and creates a dynarray with the specified minimum size.
  59.  
  60.  RETURNS
  61.     Returns pointer to the dynarray created if successful and NULL otherwise
  62.  
  63. *******************************************************************************/
  64. dynarr_p DAcreate_array(intn start_size,      /* IN: Initial array size */
  65.     intn incr_mult                  /* IN: multiple to create additional elements in */
  66. );
  67.  
  68. /******************************************************************************
  69.  NAME
  70.      DAdestroy_array - Destroy a dynarray
  71.  
  72.  DESCRIPTION
  73.     Destroy an existing dynarray from use.  This routine de-allocates the
  74.     dynarray structure and deletes the current dynarray.
  75.  
  76.  RETURNS
  77.     Returns SUCCEED if successful and FAIL otherwise
  78.  
  79. *******************************************************************************/
  80. intn DAdestroy_array(dynarr_p arr,  /* IN: Array to destroy */
  81.         intn free_elem              /* IN: whether to free each element */
  82. );
  83.  
  84. /******************************************************************************
  85.  NAME
  86.      DAdestroy_array - Get the current size of a dynarray
  87.  
  88.  DESCRIPTION
  89.     Get the number of elements in use currently.
  90.  
  91.  RETURNS
  92.     Returns # of dynarray elements if successful and FAIL otherwise
  93.  
  94. *******************************************************************************/
  95. intn DAsize_array(dynarr_p arr   /* IN: Array to get size of */
  96. );
  97.  
  98. /******************************************************************************
  99.  NAME
  100.      DAget_elem - Get an element from a dynarray
  101.  
  102.  DESCRIPTION
  103.     Retrieve an element from a dynarray.  If the element to be retrieved is
  104.     beyond the end of the currently allocated array elements, the array is
  105.     not extended, a NULL pointer is merely returned.
  106.  
  107.  RETURNS
  108.     Returns object ptr if successful and NULL otherwise
  109.  
  110. *******************************************************************************/
  111. VOIDP DAget_elem(dynarr_p arr_ptr, /* IN: Array to access */
  112.     intn elem                       /* IN: Array element to retrieve */
  113. );
  114.  
  115. /******************************************************************************
  116.  NAME
  117.      DAset_elem - Set an element pointer for a dynarray
  118.  
  119.  DESCRIPTION
  120.     Set an element pointer for a dynarray.  If the element to be set is
  121.     beyond the end of the currently allocated array elements, the array is
  122.     extended by whatever multiple of the incr_mult is needed to expand the
  123.     # of array elements to include the array element to set.
  124.  
  125.  RETURNS
  126.     Returns SUCCEED if successful and NULL otherwise
  127.  
  128. *******************************************************************************/
  129. intn DAset_elem(dynarr_p arr_ptr,  /* IN: Array to access */
  130.     intn elem,                      /* IN: Array element to set */
  131.     VOIDP obj                       /* IN: Pointer to the object to store */
  132. );
  133.  
  134. /*****************************************************************************
  135.  NAME
  136.      DAdel_elem - Delete an element from a dynarray
  137.  
  138.  DESCRIPTION
  139.     Retrieve an element from a dynarray & delete it from the dynarray.  If the
  140.     element to be retrieved is beyond the end of the currently allocated array
  141.     elements, the array is not extended, a NULL pointer is merely returned.
  142.  
  143.  RETURNS
  144.     Returns object ptr if successful and NULL otherwise
  145.  
  146. *******************************************************************************/
  147. VOIDP DAdel_elem(dynarr_p arr_ptr, /* IN: Array to access */
  148.     intn elem                       /* IN: Array element to retrieve */
  149. );
  150.  
  151. #if defined c_plusplus || defined __cplusplus
  152. }
  153. #endif                          /* c_plusplus || __cplusplus */
  154.  
  155. #endif /* __DYNARRAY_H */
  156.  
  157.