2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
7 * @file AthLinks/tools/MapIndexingPolicy.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 MapIndexingPolicy<MAP>::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 MapIndexingPolicy<CONT>::index_type
36 MapIndexingPolicy<CONT>::storedToExternal (stored_index_type index)
43 * @brief Make an index invalid.
44 * @param index[out] The index to reset.
48 void MapIndexingPolicy<MAP>::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 MapIndexingPolicy<MAP>::ElementType
64 MapIndexingPolicy<MAP>::lookup(const stored_index_type& index,
68 SG::throwExcInvalidIndex ("MapIndexingPolicy");
69 const_iterator iter = data.find(index);
70 if (iter == data.end())
71 SG::throwExcIndexNotFound ("MapIndexingPolicy");
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 MapIndexingPolicy<MAP>::reverseLookup(const MAP& 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 const_iterator it = data.begin();
96 const_iterator iend = data.end();
98 if (it->second == element) break;
107 SG::throwExcElementNotFound ("reverseLookup");