2 #ifndef GAUDIKERNEL_KEYEDCONTAINER_H
3 #define GAUDIKERNEL_KEYEDCONTAINER_H
22 #define FORCE_INLINE __forceinline
24 #define FORCE_INLINE inline
63 template <
class DATATYPE,
class MAPPING=Containers::HashMap >
66 friend struct GaudiDict::KeyedContainerDict<DATATYPE>;
83 typedef typename contained_type::key_type
key_type;
118 #ifdef CHECK_KEYED_CONTAINER
120 if ( 0 == m_cont.isDirect() ) {
121 if ( traits::checkBounds(m_random, k) ) {
122 value_type p = *(m_random->begin()+traits::hash(k));
123 if ( traits::checkKey(p, k) ) {
130 return traits::checkKey(p, k) ? p : 0;
134 return 0==m_cont.isDirect()
135 ?
value_type(*(m_random->begin()+traits::hash(k)))
143 if ( p->parent() == this ) {
167 if ( par == m_obj ) {
185 m_cont.setup((
void*)sptr,(
void**)rptr);
200 static CLID clid = contained_type::classID() + container_type::classID();
254 return i_object( traits::makeKey( key_value ) );
276 bool empty()
const {
return m_sequential.empty(); }
434 void erase(iterator pos_start, iterator pos_stop,
bool use_temp=
false);
454 const key_type& insert(
const value_type val,
const key_type& kval);
477 const key_type& insert(
const value_type val);
490 template <
class DATATYPE,
class MAPPING>
inline
493 erase(begin(),
end());
498 template <
class DATATYPE,
class MAPPING>
inline
502 m_cont.clearDirect();
505 for ( ; i !=
s; i++ ) {
508 if ( !v->hasKey() ) {
509 traits::setKey(v, v->key());
512 long k0 = traits::hash(v->key());
528 template <
class DATATYPE,
class MAPPING>
inline
532 ((0==m_cont.isDirect()) ? m_random : &m_sequential);
535 template <
class DATATYPE,
class MAPPING>
inline
541 long k0 = traits::hash(kval);
542 if ( !val->hasKey() || (traits::hash(val->key()) == k0) ) {
544 if ( !val->hasKey() ) traits::setKey(val, kval);
556 template <
class DATATYPE,
class MAPPING>
561 if ( val->hasKey() ) {
562 if (m_cont.insert(
this,val,val,traits::hash(val->key()))
570 traits::setKey(val, traits::makeKey(k0));
580 template <
class DATATYPE,
class MAPPING>
inline
584 if ( ptr )
return traits::identifier(ptr->key());
589 template <
class DATATYPE,
class MAPPING>
inline
597 for ( ; i !=
s; i++ ) {
605 template <
class DATATYPE,
class MAPPING>
inline
608 return traits::identifier(insert(dynamic_cast<typename seq_type::value_type>(pObject)));
612 template <
class DATATYPE,
class MAPPING>
inline
617 return this->erase(p1);
636 template <
class DATATYPE,
class MAPPING>
inline
642 bool is_start = start_pos == m_sequential.begin();
643 bool is_stop = stop_pos == m_sequential.end();
644 if ( is_start && is_stop ) {
647 else if ( is_start || is_stop || use_tmp ) {
649 tmp.
insert(tmp.end(), stop_pos, m_sequential.end());
651 this->erase(m_sequential.begin(), m_sequential.end());
662 m_cont.erase(i1, i2);
666 #endif // GAUDIKERNEL_KEYEDCONTAINER_H