#ifndef __TRANSCACHE_H__
#define __TRANSCACHE_H__

#include "transformation.h"
#include <map>
#include <set>

struct tctransform
{
  double x;
  double y;
};

struct tctlt
{
  bool operator()( const tctransform &a,
                   const tctransform &b ) const
  {
    if( a.x < b.x )
      return 1;
    else if( a.x == b.x )
      {
        if( a.y < b.y )
          return 1;
        else
          return 0;
      }
    return 0;
  }
};

class transcache
{
 public:
  transcache();
  ~transcache();
  int add( transformation &a );

  /// fill the score for the transformation
  /**
   * @return 0 if is in cache -1 if no in cache
   */
  int get( transformation &b );

  int size()
  {
    return data.size();
  }

  double hitfrequency();

  int getkeys( std::set< std::pair< double, double > > &s );

  int resetfreq();

 private:
  std::map< tctransform, double, tctlt > data;
  int getsuccess;
  int gettry;
};

#endif
