mirror of https://github.com/dnomd343/klotski.git
Dnomd343
3 weeks ago
6 changed files with 209 additions and 152 deletions
@ -0,0 +1,12 @@ |
|||
#pragma once |
|||
|
|||
namespace klotski::fast_cal { |
|||
|
|||
inline FCDemo::FCDemo(RawCode raw_code) : codes_(cases::GroupUnion::from_raw_code(raw_code).max_group_size(), {raw_code.unwrap()}) { |
|||
// auto reserve = cases::GroupUnion::from_raw_code(raw_code).max_group_size(); |
|||
cases_.reserve(static_cast<size_t>(25955 * 1.56)); |
|||
// cases_.reserve(static_cast<size_t>(reserve * 1.56)); |
|||
cases_.emplace(raw_code, data_t {0, 0}); // without mask |
|||
} |
|||
|
|||
} // namespace klotski::fast_cal |
@ -0,0 +1,53 @@ |
|||
#pragma once |
|||
|
|||
namespace klotski { |
|||
|
|||
template <typename T> |
|||
inline LayerQueue<T>::LayerQueue(size_t reserve, std::initializer_list<T> first_layer) { |
|||
data_.resize(reserve); |
|||
for (auto x : first_layer) { |
|||
emplace(x); |
|||
} |
|||
layer_end_ = first_layer.size(); |
|||
} |
|||
|
|||
template <typename T> |
|||
void LayerQueue<T>::emplace(T item) { |
|||
data_[queue_end_] = item; |
|||
++queue_end_; |
|||
} |
|||
|
|||
template <typename T> |
|||
T LayerQueue<T>::current() const { |
|||
return data_[queue_begin_]; |
|||
} |
|||
|
|||
template <typename T> |
|||
void LayerQueue<T>::next() { |
|||
++queue_begin_; |
|||
if (queue_begin_ == layer_end_ && !is_ending()) { |
|||
layer_begin_ = layer_end_; |
|||
layer_end_ = queue_end_; |
|||
} |
|||
} |
|||
|
|||
template <typename T> |
|||
[[nodiscard]] bool LayerQueue<T>::is_ending() const { |
|||
return queue_begin_ == queue_end_; |
|||
} |
|||
|
|||
template <typename T> |
|||
[[nodiscard]] bool LayerQueue<T>::is_new_layer() const { |
|||
return queue_begin_ == layer_begin_; |
|||
} |
|||
|
|||
template <typename T> |
|||
std::vector<T> LayerQueue<T>::layer_cases() const { |
|||
std::vector<T> layer_cases; |
|||
for (size_t offset = layer_begin_; offset < layer_end_; ++offset) { |
|||
layer_cases.emplace_back(data_[offset]); |
|||
} |
|||
return layer_cases; |
|||
} |
|||
|
|||
} // namespace klotski |
Loading…
Reference in new issue