/* * Copyright 2013 (c) Anna Schumaker. */ #include IndexEntry :: IndexEntry() { } IndexEntry :: IndexEntry(const std::string &k, unsigned int v) : key(k) { insert(v); } IndexEntry :: ~IndexEntry() { } const std::string &IndexEntry :: primary_key() { return key; } void IndexEntry :: write(File &f) { std::set::iterator it; f << key << std::endl << values.size() << " "; for (it = values.begin(); it != values.end(); it++) f << *it << " "; } void IndexEntry :: read(File &f) { unsigned int num, val; f >> key >> num; for (unsigned int i = 0; i < num; i++) { f >> val; values.insert(val); } } void IndexEntry :: print() { std::set::iterator it; :: print("{"); for (it = values.begin(); it != values.end(); it++) { if (it != values.begin()) :: print(" "); :: print("%d", *it); } :: print("}"); } void IndexEntry :: insert(unsigned int val) { values.insert(val); } void IndexEntry :: remove(unsigned int val) { values.erase(val); }