diff --git a/bit_packed_array.cpp b/bit_packed_array.cpp index dd0abfe4..0525ef85 100644 --- a/bit_packed_array.cpp +++ b/bit_packed_array.cpp @@ -66,6 +66,19 @@ void BitPackedArray::writeFile(ofstream &fp) } } +void BitPackedArray::writeFile(const char *filename) +{ + ofstream fp(filename, std::ofstream::binary); + writeFile(fp); + fp.close(); +} + +void BitPackedArray::writeFile(const string &filename) +{ + writeFile(filename.c_str()); +} + + #define read_fp(x) fp.read((char *)&(x), sizeof((x))) void BitPackedArray::readFile(ifstream &fp) @@ -114,6 +127,18 @@ void BitPackedArray::readFile(ifstream &fp) cur_ = prev_cnt; } +void BitPackedArray::readFile(const char *filename) +{ + ifstream fp(filename, std::ifstream::binary); + readFile(fp); + fp.close(); +} + +void BitPackedArray::readFile(const string &filename) +{ + readFile(filename.c_str()); +} + void BitPackedArray::put(size_t index, TIndexOffU val) { assert_lt(index, cur_); diff --git a/bit_packed_array.h b/bit_packed_array.h index 100057b1..ac84e93a 100644 --- a/bit_packed_array.h +++ b/bit_packed_array.h @@ -50,7 +50,12 @@ class BitPackedArray { void init(size_t max_value); + void writeFile(const char *filename); + void writeFile(const string& filename); void writeFile(ofstream &fp); + + void readFile(const char *filename); + void readFile(const string& filename); void readFile(ifstream &fp); void dump() const;