home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR41 / CDLLIST.ZIP / LIST.H < prev   
C/C++ Source or Header  |  1993-06-01  |  4KB  |  84 lines

  1. #define data_type    int
  2. #define name_of_list list_of_ints
  3.  
  4. struct node{data_type data; struct node *left,*right;};
  5.  
  6. struct list{struct node *head,*tail,*current_pos;};
  7.  
  8. typedef struct list name_of_list;
  9.  
  10. /*****************************************************************
  11.  *initialize_list : usage 'initialize_list(&my_list);'           *
  12.  *this must be done in order to use a newly declared list,       *
  13.  *this function will also take an existing list and make it empty*
  14.  *****************************************************************/
  15. void initialize_list(name_of_list *a);
  16.  
  17. /*********************************************************************
  18.  *goto_head : usage 'goto_head(&my_list);'                           *
  19.  *this function will set the current position of the list to the head*
  20.  *********************************************************************/
  21. void goto_head(name_of_list *a);
  22.  
  23. /********************************************************************
  24.  *got_tail : usage 'goto_tail(&my_list);'                           *
  25.  *this function will set the current postion of the list to the tail*
  26.  ********************************************************************/
  27. void goto_tail(name_of_list *a);
  28.  
  29. /********************************************************************
  30.  *goto_right : usage 'goto_right(&my_list);'                        *
  31.  *this function will move the current position of the list one node *
  32.  *to the right, if no nodes exist nothing will happen               *
  33.  ********************************************************************/
  34. void goto_right(name_of_list *a);
  35.  
  36. /*********************************************************************
  37.  *goto_left : usage 'goto_left(&my_list));'                          *
  38.  *this function will move the current position of the list one node  *
  39.  *to the left, if no nodes exist nothing will happen                 *
  40.  *********************************************************************/
  41. void goto_left(name_of_list *a);
  42.  
  43. /*********************************************************************
  44.  *insert_before_cur : usage 'insert_before_cur(&my_list,id_num);'    *
  45.  *this function will insert a new node containing id_num into the    *
  46.  *list before the current position                                   *
  47.  *********************************************************************/
  48. void insert_before_cur(name_of_list *a,data_type b);
  49.  
  50. /*********************************************************************
  51.  *insert_after_cur : usage 'insert_after_cur(&my_list,id_num);'      *
  52.  *this function will insert a new node containing id_num into the    *
  53.  *list after the current position                                    *
  54.  *********************************************************************/
  55. void insert_after_cur(name_of_list *a,data_type b);
  56.  
  57. /*********************************************************************
  58.  *retrieve_current : usage 'new_data=retrieve_current(&my_list);'    *
  59.  *this function will return the data stored in the current node      *
  60.  *********************************************************************/
  61. data_type  retrieve_current(name_of_list *a);
  62.  
  63. /*********************************************************************
  64.  *position : usage 'offset=position(&my_list,key);'                  *
  65.  *this function will return the offset from the current position     *
  66.  *where the desired key was found, if the end of list is reached the *
  67.  *function returns -1                                                *
  68.  *********************************************************************/
  69. int  position(name_of_list *a,data_type b);
  70.  
  71. /*********************************************************************
  72.  *size : usage 'length=size(&my_list);'                              *
  73.  *this function returns the size/length of the list in question      *
  74.  *a list with one node will return 1, with two nodes returns 2, etc  *
  75.  *********************************************************************/
  76. int  size(name_of_list *a);
  77.  
  78. /*********************************************************************
  79.  *delete_at_current : usage 'delete_at_current(&my_list);'           *
  80.  *this function deletes the current position node                    *
  81.  *********************************************************************/
  82. void delete_at_current(name_of_list *a);
  83.  
  84.