2 Stockfish, a UCI chess playing engine derived from Glaurung 2.1
3 Copyright (C) 2004-2020 The Stockfish developers (see AUTHORS file)
5 Stockfish is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 Stockfish is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 // Definition of index list of input features
21 #ifndef NNUE_FEATURES_INDEX_LIST_H_INCLUDED
22 #define NNUE_FEATURES_INDEX_LIST_H_INCLUDED
24 #include "../../position.h"
25 #include "../nnue_architecture.h"
27 namespace Eval::NNUE::Features {
29 // Class template used for feature index list
30 template <typename T, std::size_t MaxSize>
34 std::size_t size() const { return size_; }
35 void resize(std::size_t size) { size_ = size; }
36 void push_back(const T& value) { values_[size_++] = value; }
37 T& operator[](std::size_t index) { return values_[index]; }
38 T* begin() { return values_; }
39 T* end() { return values_ + size_; }
40 const T& operator[](std::size_t index) const { return values_[index]; }
41 const T* begin() const { return values_; }
42 const T* end() const { return values_ + size_; }
44 void swap(ValueList& other) {
45 const std::size_t max_size = std::max(size_, other.size_);
46 for (std::size_t i = 0; i < max_size; ++i) {
47 std::swap(values_[i], other.values_[i]);
49 std::swap(size_, other.size_);
54 std::size_t size_ = 0;
57 //Type of feature index list
59 : public ValueList<IndexType, RawFeatures::kMaxActiveDimensions> {
62 } // namespace Eval::NNUE::Features
64 #endif // NNUE_FEATURES_INDEX_LIST_H_INCLUDED