|
ATLAS Offline Software
|
Go to the documentation of this file.
19 template<
class SetA,
class SetB,
typename Compare = std::less<>>
21 share_element(SetA&& setA, SetB&& setB, Compare
comp = Compare{}){
22 auto xA = setA.begin();
23 auto xB = setB.begin();
24 while (xA != setA.end() && xB != setB.end()){
27 }
else if (
comp(*xB, *xA)) {
41 size_t indices = get_indices ();
54 return (
value - m_minimum);
56 if (not m_indexes.empty()) {
58 assert (
value >= m_minimum &&
value - m_minimum < (
int)m_indexes.size());
59 return (m_indexes.at(
value - m_minimum));
61 const auto &
v = get_values();
62 auto it = std::ranges::lower_bound(
v,
value);
72 return ((
value >= m_minimum) && (
value <= m_maximum));
74 if (m_empty)
return true;
75 const auto &
v = get_values();
76 return (std::ranges::binary_search(
v,
value));
93 set(minimum, maximum);
202 for (
const auto &
v:
ev) {
208 for (
const auto &
v:
ev){
209 if ((
v >=
other.m_minimum) and (
v <=
other.m_maximum))
return (
true);
237 if (minimum == maximum) {
250 if (
auto *
p = dataPtr<element_vector>(); !
p) {
256 if (std::ranges::binary_search(*
p,
value))
return;
258 std::ranges::sort(*
p);
269 auto *
p = dataPtr<element_vector>();
272 p = dataPtr<element_vector>();
275 std::ranges::sort (*
p);
277 p->erase( std::unique(
p->begin(),
p->end() ),
p->end() );
342 IdentifierField::operator std::string ()
const {
347 const auto & [minimum, maximum] = get_minmax();
348 if (minimum == maximum) {
351 if (isEnumerated()) {
377 std::cout <<
"values ";
379 std::cout <<
v <<
" ";
381 std::cout <<
"indexes ";
383 std::cout <<
idx <<
" ";
385 std::cout <<
"indices " <<
m_size <<
" ";
387 std::cout <<
"next " <<
m_next <<
" ";
388 std::cout <<
"mode ";
390 std::cout <<
"unbounded ";
392 std::cout <<
"both_bounded ";
394 std::cout <<
"enumerated ";
396 std::cout <<
"cont mode ";
399 std::cout <<
"none ";
402 std::cout <<
"has_next ";
405 std::cout <<
"has_previous ";
408 std::cout <<
"has_both ";
411 std::cout <<
"has_wrap_around ";
414 std::cout << std::endl;
457 auto &
v = std::get<element_vector>(
m_data);
458 for (
const auto & thisValue:
v) {
463 std::cout <<
"size, value, index, i "
464 <<
size <<
" " << thisValue <<
" "
465 <<
index <<
" " <<
i++ <<
" min, max "
484 while (std::isspace(is.peek())){is.ignore();}
490 if (
c ==
'+') is.ignore();
496 std::vector<int>
vec(1,
v);
498 vec.insert(
vec.end(), restOfList.begin(), restOfList.end());
500 }
else if (
c ==
':'){
511 std::string
msg{
"Stream extraction for IdentifierField: "};
515 throw std::invalid_argument(
msg);
size_type get_bits() const
ExpandedIdentifier::element_type element_type
bool overlaps_with(const IdentifierField &other) const
Check whether two IdentifierFields overlap.
static constexpr int m_maxNumberOfIndices
std::pair< long int, long int > indices
IdentifierField::element_type parseStreamDigits(std::istream &is)
std::istream & operator>>(std::istream &is, IdentifierField &idf)
const element_vector & get_values() const
void set(element_type minimum, element_type maximum)
std::vector< size_t > vec
continuation_mode m_continuation_mode
IdentifierField::element_vector parseStreamList(std::istream &is)
void create_index_table()
Create index table from value table.
typename vecDetail::vec_typedef< T, N >::type vec
Define a nice alias for the vectorized type.
bool match(element_type value) const
The basic match operation.
size_type get_value_index(element_type value) const
bool isDigit(const char c)
bool operator==(const IdentifierField &other) const
static constexpr auto minimum_possible
std::variant< element_vector, BoundedRange > m_data
bool get_next(element_type current, element_type &next) const
std::ostream & operator<<(std::ostream &out, const IdentifierField &c)
bool isEnumerated() const
boost::container::small_vector< element_type, 12 >::size_type size_type
std::vector< element_type > element_vector
void set_previous(int previous)
bool check_for_both_bounded()
Check mode - switch from enumerated to both_bounded if possible.
ExpandedIdentifier::size_type size_type
static constexpr auto maximum_possible
std::string to_string(const DetectorType &type)
void operator|=(const IdentifierField &other)
This is the individual specification for the range of one ExpandedIdentifier IdentifierField.
std::pair< element_type, element_type > BoundedRange
bool get_previous(element_type current, element_type &previous) const
Returns false if previous/next is at end of range, or not possible.
void optimize()
Optimize - try to switch mode to both_bounded, set up lookup table for finding index from value.
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space
void add_value(element_type value)
IdentifierField()=default
Create a wild-card value.