-
Notifications
You must be signed in to change notification settings - Fork 90
Expand file tree
/
Copy pathaaron_utils.cpp
More file actions
23 lines (20 loc) · 822 Bytes
/
aaron_utils.cpp
File metadata and controls
23 lines (20 loc) · 822 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include "aaron_utils.hpp"
int testForError(FILE * x) { return x==NULL; }
int testForError(int x) { return x==-1; }
string show(long x) { ostringstream s; s << x; return s.str(); }
string show(const char * x) { ostringstream s; s << x; return s.str(); }
string show(const string &s) { return s; }
runningAverage::runningAverage() : total(0) , n(0) {}
void runningAverage::operator() (long int i) {
total+=i;
if(total<0) Die("total overflowed %ld", i);
n++;
}
string runningAverage::operator() (void) const {
ostringstream o;
o << "Average Time (" << n << " points)" << ": " << (double)total/(double)n;
return o.str();
}
DummyOutputStream& DummyOutputStream::operator << (int) { return *this; }
DummyOutputStream& DummyOutputStream::operator << (const char*) { return *this; }
DummyOutputStream dummyOutputStream;