Skip to content

Commit

Permalink
rework how ids are passed to facets
Browse files Browse the repository at this point in the history
  • Loading branch information
jll63 committed Feb 19, 2024
1 parent 7ab2b99 commit 4d36112
Show file tree
Hide file tree
Showing 11 changed files with 498 additions and 461 deletions.
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ IncludeIsMainRegex: '(Test)?$'
IncludeIsMainSourceRegex: ''
IndentCaseLabels: false
IndentGotoLabels: true
IndentPPDirectives: None
IndentPPDirectives: true
IndentWidth: 4
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
Expand Down
57 changes: 45 additions & 12 deletions include/yorel/yomm2/detail.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,23 +171,52 @@ const char* default_method_name() {
#endif
}

// -------------
// hash function
// -----------------------------------------------------------------------------
// iterator adapter for passing range from external_vpt to fast_perfect_hash

template<class PairIterator>
class pair_first_iterator {
PairIterator iter;

struct hash_function {
type_id mult;
std::size_t shift;
public:
using iterator_category = typename std::forward_iterator_tag;
using difference_type = typename PairIterator::difference_type;
using value_type = decltype(std::declval<PairIterator>()->first);
using pointer = const value_type*;
using reference = const value_type&;

auto operator()(type_id tip) const {
return (mult * tip) >> shift;
explicit pair_first_iterator(PairIterator iter) : iter(iter) {
}
};

inline std::size_t hash(type_id mult, std::size_t shift, type_id value) {
return static_cast<std::size_t>((mult * value) >> shift);
}
reference operator*() const {
return iter->first;
}

// ----------
pointer operator->() const {
return &iter->first;
}

pair_first_iterator& operator++() {
++iter;
return *this;
}

pair_first_iterator operator++(int) const {
return pair_first_iterator(iter++);
}

friend bool
operator==(const pair_first_iterator& a, const pair_first_iterator& b) {
return a.iter == b.iter;
}

friend bool
operator!=(const pair_first_iterator& a, const pair_first_iterator& b) {
return a.iter != b.iter;
}
};

// -----------------------------------------------------------------------------
// class info

struct class_info : static_chain<class_info>::static_link {
Expand Down Expand Up @@ -693,6 +722,10 @@ struct ostdstream {
}
};

struct ostderr : ostdstream {
ostderr() : ostdstream(stderr) {}
};

inline ostdstream cerr;

inline ostdstream& operator<<(ostdstream& os, const char* str) {
Expand Down
Loading

0 comments on commit 4d36112

Please sign in to comment.