Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

57 lines (44 sloc) 0.812 kb
#include "index.h"
#include <algorithm>
InvertedIndex::InvertedIndex()
{
}
void InvertedIndex::add(key k, row_num r)
{
if (index[k].size() == 0)
{
index[k].push_back(r);
return;
}
if (std::find(index[k].begin(), index[k].end(), r) == index[k].end())
{
index[k].push_back(r);
}
}
bool InvertedIndex::remove(key k, row_num r)
{
if (index[k].size() == 0)
return false;
row_num_list::iterator p = std::find(index[k].begin(), index[k].end(), r);
if (index[k].end() != p)
{
index[k].erase(p);
return true;
}
return false;
}
InvertedIndex::row_num_list InvertedIndex::get(key k)
{
return index[k];
}
InvertedIndex::key_list InvertedIndex::keys()
{
key_list r;
index_type::iterator i = index.begin();
while(i != index.end())
{
r.push_back((*i).first);
++i;
}
return r;
}
Jump to Line
Something went wrong with that request. Please try again.