2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
7 * @file AthLinks/tools/SetIndexingPolicy.icc
8 * @author scott snyder <snyder@bnl.gov>
10 * @brief Indexing policy for a set-like container.
18 * @brief Test to see if an index is valid.
19 * @param index The index to test.
23 bool SetIndexingPolicy<SET>::isValid (const stored_index_type& index)
25 return index.isValid();
30 * @brief Convert from stored to external index types.
31 * @param index The stored index.
35 typename SetIndexingPolicy<CONT>::index_type
36 SetIndexingPolicy<CONT>::storedToExternal (stored_index_type index)
43 * @brief Make an index invalid.
44 * @param index[out] The index to reset.
48 void SetIndexingPolicy<SET>::reset (stored_index_type& index)
55 * @brief Retrieve from a container the element corresponding to an index.
56 * @param index The index to fetch.
57 * @param data The container.
59 * Will throw SG::ExcInvalidIndex if the index is invalid and
60 * SG::ExcIndexNotFound if the index is not in the container.
63 typename SetIndexingPolicy<SET>::ElementType
64 SetIndexingPolicy<SET>::lookup(const stored_index_type& index,
68 SG::throwExcInvalidIndex ("SetIndexingPolicy");
69 iterator iter = data.find(index);
70 if (iter == data.end())
71 SG::throwExcIndexNotFound ("SetIndexingPolicy");
77 * @brief Find the index of the (first) instance of ELEMENT in DATA.
78 * @param data The container to search.
79 * @param element The element to find.
80 * @param index[out] The index in the container of @c element.
82 * Throws SG::ExcElementNotFound if the element is not in the container.
86 SetIndexingPolicy<SET>::reverseLookup(const SET& data,
87 ElementConstReference element,
90 //compiler checks we can compare elements
91 ::boost::function_requires<typename ::boost::EqualityComparableConcept<ElementType> >();
93 // Note that reverseLookup will recalculate index even if m_valid is true.
94 // Must ensure that index is write before persistency
95 if (data.end() != data.find(element))
100 SG::throwExcElementNotFound ("reverseLookup");