// Sets the mapped_features_ from the features_ using the provided
// feature_space to the indexed versions of the features.
void TrainingSample::IndexFeatures(const IntFeatureSpace& feature_space) {
  GenericVector<int> indexed_features;
  feature_space.IndexAndSortFeatures(features_, num_features_,
                                     &mapped_features_);
  features_are_indexed_ = true;
  features_are_mapped_ = false;
}
// Display the samples with the given indexed feature that also match
// the given shape.
    void TrainingSampleSet::DisplaySamplesWithFeature(int f_index,
                                                      const Shape &shape,
                                                      const IntFeatureSpace &space,
                                                      ScrollView::Color color,
                                                      ScrollView *window) const {
        for (int s = 0; s < num_raw_samples(); ++s) {
            const TrainingSample *sample = GetSample(s);
            if (shape.ContainsUnichar(sample->class_id())) {
                GenericVector <int> indexed_features;
                space.IndexAndSortFeatures(sample->features(), sample->num_features(),
                                           &indexed_features);
                for (int f = 0; f < indexed_features.size(); ++f) {
                    if (indexed_features[f] == f_index) {
                        sample->DisplayFeatures(color, window);
                    }
                }
            }
        }
    }