File: array.cc

package info (click to toggle)
abacus 0.9.13-3
  • links: PTS
  • area: main
  • in suites: slink
  • size: 6,308 kB
  • ctags: 5,121
  • sloc: ansic: 27,541; cpp: 11,425; tcl: 7,564; makefile: 386; yacc: 327; lex: 265; sh: 221
file content (65 lines) | stat: -rw-r--r-- 1,104 bytes parent folder | download | duplicates (2)
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
56
57
58
59
60
61
62
63
64
65
// $Id: array.cc,v 1.2 1995/12/30 14:52:43 aml Exp $

#include "utils.hh"
#include "array.hh"

/* Hpux C++ compiler does not handle template functions in header files */

#ifdef hpux 

template<class T>
ostream &operator<<(ostream &s, array<T> &arr) {
    int i;
    
    s << arr.cnt << "\n";
    for(i=0; i<arr.cnt; i++) 
        s << arr[i] << " ";
    return(s);
} 


template<class T>
int operator<=(const T &elem, array<T> &arr) {
    int i;
    
    for(i=0; i<arr.cnt; i++) 
        if (arr[i] == elem) return(TRUE);
    
    return(FALSE);
} 


template<class T>
ofstream &operator<<(ofstream &s, array<T> &arr) {
    int i;
    
    s << arr.cnt << "\n";
    for(i=0; i<arr.cnt; i++) 
        s << arr[i] << " ";
    return(s);
} 

template<class T>
istream &operator>>(istream &s, array<T> &arr) {
    int i;
    
    
    s >> arr.cnt;
    for(i=0; i<arr.cnt; i++) 
        s >> arr[i];
    return(s);
} 

template<class T>
ifstream &operator>>(ifstream &s, array<T> &arr) {
    int i;
    
    
    s >> arr.cnt;
    for(i=0; i<arr.cnt; i++) 
        s >> arr[i];
    return(s);
} 


#endif