 |
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 const auto &
v = get_values();
57 if (
v.size()==1)
return 0;
58 if (not m_indexes.empty()) {
60 assert (
value >= m_minimum &&
value - m_minimum < (
int)m_indexes.size());
61 return (m_indexes.at(
value - m_minimum));
73 return ((
value >= m_minimum) && (
value <= m_maximum));
75 if (m_empty)
return true;
76 const auto &
v = get_values();
94 set(minimum, maximum);
203 for (
const auto &
v:
ev) {
209 for (
const auto &
v:
ev){
210 if ((
v >=
other.m_minimum) and (
v <=
other.m_maximum))
return (
true);
238 if (minimum == maximum) {
251 if (
auto *
p = dataPtr<element_vector>(); !
p) {
257 if (std::ranges::binary_search(*
p,
value))
return;
259 std::ranges::sort(*
p);
270 auto *
p = dataPtr<element_vector>();
273 p = dataPtr<element_vector>();
276 std::ranges::sort (*
p);
278 p->erase( std::unique(
p->begin(),
p->end() ),
p->end() );
343 IdentifierField::operator std::string ()
const {
348 const auto & [minimum, maximum] = get_minmax();
349 if (minimum == maximum) {
352 if (isEnumerated()) {
378 std::cout <<
"values ";
380 std::cout <<
v <<
" ";
382 std::cout <<
"indexes ";
384 std::cout <<
idx <<
" ";
386 std::cout <<
"indices " <<
m_size <<
" ";
388 std::cout <<
"next " <<
m_next <<
" ";
389 std::cout <<
"mode ";
391 std::cout <<
"unbounded ";
393 std::cout <<
"both_bounded ";
395 std::cout <<
"enumerated ";
397 std::cout <<
"cont mode ";
400 std::cout <<
"none ";
403 std::cout <<
"has_next ";
406 std::cout <<
"has_previous ";
409 std::cout <<
"has_both ";
412 std::cout <<
"has_wrap_around ";
415 std::cout << std::endl;
458 auto &
v = std::get<element_vector>(
m_data);
459 for (
const auto & thisValue:
v) {
464 std::cout <<
"size, value, index, i "
465 <<
size <<
" " << thisValue <<
" "
466 <<
index <<
" " <<
i++ <<
" min, max "
485 while (std::isspace(is.peek())){is.ignore();}
491 if (
c ==
'+') is.ignore();
497 std::vector<int>
vec(1,
v);
499 vec.insert(
vec.end(), restOfList.begin(), restOfList.end());
501 }
else if (
c ==
':'){
512 std::string
msg{
"Stream extraction for IdentifierField: "};
516 throw std::invalid_argument(
msg);
size_type get_bits() const
std::string find(const std::string &s)
return a remapped string
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.