2 * Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration.
5 * @file AthContainers/PackedLinkImpl.icc
6 * @author scott snyder <snyder@bnl.gov>
8 * @brief Definition of PackedLink type.
16 * @brief Default constructor.
18 * Initialize a null link.
21 PackedLinkBase::PackedLinkBase()
29 * @param collection The index of the collection in the @c DataLink vector,
30 * @param index The index of the element within the collection.
33 PackedLinkBase::PackedLinkBase (unsigned int collection, unsigned int index) :
34 m_packed ((collection << INDEX_NBITS) + index)
36 assert (index <= INDEX_MAX);
37 assert (collection <= COLLECTION_MAX);
43 * @param other The link with which to compare.
46 bool PackedLinkBase::operator== (const PackedLinkBase& other) const
48 return m_packed == other.m_packed;
53 * @brief Unpack the collection index from the link.
56 unsigned int PackedLinkBase::collection() const
58 return m_packed >> INDEX_NBITS;
63 * @brief Unpack the element index from the link.
66 unsigned int PackedLinkBase::index() const
68 return (m_packed & INDEX_MAX);
73 * @brief Set the collection index;
74 * @param collection The index of the collection in the @c DataLink vector,
77 void PackedLinkBase::setCollection (unsigned int collection)
79 assert (collection <= COLLECTION_MAX);
80 m_packed = (m_packed & INDEX_MAX) | (collection << INDEX_NBITS);
85 * @brief Set the element index;
86 * @param index The index of the element within the collection.
89 void PackedLinkBase::setIndex (unsigned int index)
91 assert (index <= INDEX_MAX);
92 m_packed = (m_packed & (COLLECTION_MAX << INDEX_NBITS)) | index;