File: MoveMarker.h

package info (click to toggle)
pentobi 29.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,892 kB
  • sloc: cpp: 25,719; javascript: 875; xml: 40; makefile: 13; sh: 6
file content (54 lines) | stat: -rw-r--r-- 1,246 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//-----------------------------------------------------------------------------
/** @file libpentobi_base/MoveMarker.h
    @author Markus Enzenberger
    @copyright GNU General Public License version 3 or later */
//-----------------------------------------------------------------------------

#ifndef LIBPENTOBI_BASE_MOVE_MARKER_H
#define LIBPENTOBI_BASE_MOVE_MARKER_H

#include <array>
#include "Move.h"

namespace libpentobi_base {

//-----------------------------------------------------------------------------

class MoveMarker
{
public:
    MoveMarker() { clear(); }

    bool operator[](Move mv) const { return m_a[mv.to_int()]; }

    void set(Move mv) { m_a[mv.to_int()] = true; }

    void clear(Move mv) { m_a[mv.to_int()] = false; }

    template<class T>
    void set(const T& t)
    {
        for (Move mv : t)
            set(mv);
    }

    template<class T>
    void clear(const T& t)
    {
        for (Move mv : t)
            clear(mv);
    }

    void set() { m_a.fill(true); }

    void clear() { m_a.fill(false); }

private:
    std::array<bool, Move::range> m_a;
};

//-----------------------------------------------------------------------------

} // namespace libpentobi_base

#endif // LIBPENTOBI_BASE_MOVE_MARKER_H