File: IO.c

package info (click to toggle)
spooles 2.2-14
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 19,680 kB
  • sloc: ansic: 146,836; sh: 7,571; csh: 3,615; makefile: 1,969; perl: 74
file content (55 lines) | stat: -rw-r--r-- 1,539 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*  IO.c  */

#include "../I2Ohash.h"

/*--------------------------------------------------------------------*/
/*
   ------------------------------------------------
   purpose -- to write the I2Ohash object to a file

   created -- 98jan29, cca
   ------------------------------------------------
*/
void
I2Ohash_writeForHumanEye ( 
   I2Ohash   *hashtable,
   FILE     *fp 
) {
double    measure ;
int       count, loc, nfull ;
I2OP      *i2op ;

if ( hashtable == NULL || fp == NULL ) {
   fprintf(stderr, "\n fatal error in I2Ohash_writeForHumanEye(%p,%p)"
           "\n hashtable is NULL or file pointer is NULL", 
           hashtable, fp) ;
   exit(-1) ;
}
fprintf(fp, "\n\n I2Ohash : %d lists, %d items", 
        hashtable->nlist, hashtable->nitem) ;
nfull   = 0 ;
measure = 0.0 ;
for ( loc = 0 ; loc < hashtable->nlist ; loc++ ) {
   if ( (i2op = hashtable->heads[loc]) != NULL ) {
      fprintf(fp, "\n %4d : ", loc) ;
      count = 0 ;
      while ( i2op != NULL ) {
         if ( ++count % 4 == 0 ) {
            fprintf(fp, "\n") ;
         }
         fprintf(fp, " < %6d, %6d, %p >", 
                 i2op->value0, i2op->value1, i2op->value2) ;
         i2op = i2op->next ;
      }
      measure += (double)count*(double)count ;
      nfull++ ;
   }
}
measure = sqrt(measure) ;
fprintf(fp, "\n %d empty lists, %d items, %.3f ratio",
        nfull, hashtable->nitem, 
        measure*sqrt((double) hashtable->nlist)/hashtable->nitem) ;

return ; }

/*--------------------------------------------------------------------*/