www.pudn.com > libpmk.rar > point-set.cc, change:2007-05-27,size:1361b


// Copyright 2007, Massachusetts Institute of Technology.
// The use of this code is permitted for research only. There is
// absolutely no warranty for this software.
//
// Author: John Lee (jjl@mit.edu)
//

#include <assert.h>
#include "point_set/point-set.h"
#include "point_set/feature.h"

namespace libpmk {

PointSet::PointSet(int feature_dim) : feature_dim_(feature_dim) { }

int PointSet::GetNumFeatures() const {
   return features_.size();
}

int PointSet::GetFeatureDim() const {
   return feature_dim_;
}

Feature PointSet::GetFeature(int index) const {
   assert(features_[index].GetDim() == feature_dim_);
   return features_.at(index);
}

void PointSet::AddFeature(const Feature& feature) {
   assert(feature.GetDim() == feature_dim_);
   features_.push_back(feature);
}

void PointSet::SetFeature(int index, const Feature& feature) {
   assert(index < GetNumFeatures());
   assert(feature.GetDim() == feature_dim_);
   features_.at(index) = feature;
}

void PointSet::RemoveFeature(int index) {
   assert(index < GetNumFeatures());
   features_.erase(features_.begin() + index);
}

Feature& PointSet::operator[](int index) {
   assert(index < GetNumFeatures());
   return features_.at(index);
}

const Feature& PointSet::operator[](int index) const {
   assert(index < GetNumFeatures());
   return features_.at(index);
}

}  // namespace libpmk