checkDuplicate.h
Go to the documentation of this file.
#ifndef _OSL_RECORD_CHECK_DUPLICATE_H
#define _OSL_RECORD_CHECK_DUPLICATE_H
#include "osl/basic_type.h"
#include "osl/hashKey.h"
#include "osl/pathEncoding.h"
#include <unordered_map>
#include <deque>
#include <vector>
namespace osl
{
namespace record
{
class CheckDuplicate
{
typedef std::unordered_map<HashKey, std::vector<PathEncoding>, std::hash<HashKey>> keymap_t;
keymap_t keys;
size_t regist_counter;
size_t duplicated_hash_counter;
size_t duplicated_moves_counter;
public:
static std::pair<HashKey,PathEncoding> getLastState(const std::vector<Move>& moves);
enum DUPLICATE_RESULT
{
NO_DUPLICATE = 0,
HASH_DUPLICATE = 1,
MOVES_DUPLICATE = 2
};
CheckDuplicate()
: regist_counter(0),
duplicated_hash_counter(0),
duplicated_moves_counter(0)
{}
DUPLICATE_RESULT regist(const std::vector<Move>& moves);
void print(std::ostream& out) const;
size_t getRegists() const
{ return regist_counter; }
size_t getDuplicatedHash() const
{ return duplicated_hash_counter; }
size_t getDuplicatedMoves() const
{ return duplicated_moves_counter; }
private:
DUPLICATE_RESULT regist(const HashKey& key,
const PathEncoding& moves);
};
} // namespace record
} // namespace osl
#endif /* _OSL_RECORD_CHECK_DUPLICATE_H */
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; End:
basic_type.h
osl::hash::HashKey
Definition hashKey.h:153
osl::record::CheckDuplicate::DUPLICATE_RESULT
DUPLICATE_RESULT
Result type of checking duplicates.
Definition checkDuplicate.h:38
osl::record::CheckDuplicate::HASH_DUPLICATE
@ HASH_DUPLICATE
Definition checkDuplicate.h:40
osl::record::CheckDuplicate::NO_DUPLICATE
@ NO_DUPLICATE
Definition checkDuplicate.h:39
osl::record::CheckDuplicate::MOVES_DUPLICATE
@ MOVES_DUPLICATE
Definition checkDuplicate.h:41
osl::record::CheckDuplicate::getRegists
size_t getRegists() const
Return a couter of registings (trials).
Definition checkDuplicate.h:72
osl::record::CheckDuplicate::getDuplicatedHash
size_t getDuplicatedHash() const
Return a counter of duplicated ending states.
Definition checkDuplicate.h:79
osl::record::CheckDuplicate::keys
keymap_t keys
container of moves
Definition checkDuplicate.h:23
osl::record::CheckDuplicate::duplicated_hash_counter
size_t duplicated_hash_counter
counter for hash matches with different moves
Definition checkDuplicate.h:27
osl::record::CheckDuplicate::getLastState
static std::pair< HashKey, PathEncoding > getLastState(const std::vector< Move > &moves)
Definition checkDuplicate.cc:7
osl::record::CheckDuplicate::duplicated_moves_counter
size_t duplicated_moves_counter
counter for exact matches of moves
Definition checkDuplicate.h:29
osl::record::CheckDuplicate::getDuplicatedMoves
size_t getDuplicatedMoves() const
Return a counter of duplicated moves.
Definition checkDuplicate.h:85
osl::record::CheckDuplicate::regist
DUPLICATE_RESULT regist(const std::vector< Move > &moves)
Insert a key if the key is new.
Definition checkDuplicate.cc:21
osl::record::CheckDuplicate::regist_counter
size_t regist_counter
couter for registing (trials)
Definition checkDuplicate.h:25
osl::record::CheckDuplicate::keymap_t
std::unordered_map< HashKey, std::vector< PathEncoding >, std::hash< HashKey > > keymap_t
Definition checkDuplicate.h:21
osl::record::CheckDuplicate::print
void print(std::ostream &out) const
Output the result.
Definition checkDuplicate.cc:60
osl::record::CheckDuplicate::CheckDuplicate
CheckDuplicate()
Constructor.
Definition checkDuplicate.h:47
hashKey.h
PathEncoding
Definition pathEncoding.cc:12
osl::record
棋譜関係
Definition checkDuplicate.h:15
osl
Definition additionalEffect.h:6
pathEncoding.h
std::hash
Definition basic_type.h:1354