Changeset 339


Ignore:
Timestamp:
09/23/14 02:04:41 (11 years ago)
Author:
epyon
Message:
  • handle - index_store/entity_store is_valid added
  • handle - packed_indexed_array will silently ignore invalid removes
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/nv/core/handle.hh

    r333 r339  
    103103                {
    104104                        std::swap( m_entries[ h1.index() ].index, m_entries[ h2.index() ].index );
     105                }
     106
     107                bool is_valid( handle h ) const
     108                {
     109                        typedef handle_operator<HANDLE> hop;
     110                        if ( h.is_nil() ) return false;
     111                        if ( h.index() >= m_entries.size() ) return false;
     112                        const index_entry& entry = m_entries[ h.index() ];
     113                        return entry.index >= 0 && entry.counter == hop::get_counter(h);
    105114                }
    106115
     
    183192                void remove( handle h )
    184193                {
     194                        if ( h.is_nil() || h.index() >= m_indexes.size() || m_indexes[h.index()] == -1 )
     195                                return;
    185196                        handle swap_handle    = m_handles.back();
    186197                        sint32 dead_eindex    = m_indexes[ h.index() ];
     
    259270                        m_handles.push_back( m_indexes.create_handle( sint32( m_data.size() - 1 ) ) );
    260271                        return m_handles.back();
     272                }
     273
     274                bool is_valid( handle h )
     275                {
     276                        return m_indexes.is_valid(h);
    261277                }
    262278
Note: See TracChangeset for help on using the changeset viewer.