home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume8 / graph+ / part03 / select.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-03-01  |  895 b   |  44 lines

  1. /*
  2.  * Copyright (C) 1986   Alan Kent
  3.  *
  4.  * Permission is granted to freely distribute part or
  5.  * all of this code as long as it is not for profit
  6.  * and this message is retained in the code.
  7.  *
  8.  * No resposibility is taken for any damage or incorect
  9.  * results this program generates.
  10.  * 
  11.  */
  12.  
  13.  
  14. #include <stdio.h>
  15. #include "graph.h"
  16.  
  17.  
  18. table_st *
  19. select ( table , attr_expr )
  20. table_st *table;
  21. attr_st *attr_expr;
  22. {
  23.     double eval ();
  24.  
  25.     int i , j;
  26.  
  27.  
  28.     /* if any line is not selected, simply copy all following lines */
  29.     /* back over it. This means the array may be actually larger than */
  30.     /* necessary for the data, but it is a lot easier!!! */
  31.  
  32.     j = 0;
  33.     for ( i = 0; i < table->size; i++ ) {
  34.     if ( eval ( table , i , attr_expr ) != 0.0 ) { /* True */
  35.         /* save copy */
  36.         copy_entry ( table , j , i );
  37.         j++;
  38.     }
  39.     }
  40.     table->size -= i - j;
  41.     return ( table );
  42. }
  43.  
  44.