Panda3D
Classes | Public Types | Public Member Functions
ordered_vector< Key, Compare > Class Template Reference

This template class presents an interface similar to the STL set or multiset (and ov_set and ov_multiset are implemented specifically, below), but it is implemented using a vector that is kept always in sorted order. More...

#include "ordered_vector.h"

Inheritance diagram for ordered_vector< Key, Compare >:
ov_multiset< Key, Compare > ov_set< Key, Compare >

List of all members.

Classes

class  EquivalentTest

Public Types

typedef const_iterator_0 const_iterator
typedef Vector::const_iterator const_iterator_0
typedef const_reference_0 const_reference
typedef const Key & const_reference_0
typedef const_reverse_iterator_0 const_reverse_iterator
typedef
Vector::const_reverse_iterator 
const_reverse_iterator_0
typedef difference_type_0 difference_type
typedef Vector::difference_type difference_type_0
typedef iterator_0 iterator
typedef Vector::iterator iterator_0
typedef key_compare_0 key_compare
typedef Compare key_compare_0
typedef key_type_0 key_type
typedef Key key_type_0
typedef reference_0 reference
typedef Key & reference_0
typedef reverse_iterator_0 reverse_iterator
typedef Vector::reverse_iterator reverse_iterator_0
typedef size_type_0 size_type
typedef Vector::size_type size_type_0
typedef value_compare_0 value_compare
typedef Compare value_compare_0
typedef value_type_0 value_type
typedef Key value_type_0

Public Member Functions

 ordered_vector (TypeHandle type_handle=ov_set_type_handle)
 ordered_vector (const Compare &compare, TypeHandle type_handle=ov_set_type_handle)
 ordered_vector (const ordered_vector< Key, Compare > &copy)
iterator_0 begin ()
 Returns the iterator that marks the first element in the ordered vector.
const_iterator_0 begin () const
 Returns the iterator that marks the first element in the ordered vector.
void clear ()
 Removes all elements from the ordered vector.
size_type_0 count (const key_type_0 &key) const
 Returns the number of elements that sort equivalent to the key that are in the vector.
bool empty () const
 Returns true if the ordered vector is empty, false otherwise.
iterator_0 end ()
 Returns the iterator that marks the end of the ordered vector.
const_iterator_0 end () const
 Returns the iterator that marks the end of the ordered vector.
pair< iterator_0, iterator_0 > equal_range (const key_type_0 &key)
pair< const_iterator_0,
const_iterator_0 > 
equal_range (const key_type_0 &key) const
iterator_0 erase (iterator_0 position)
size_type_0 erase (const key_type_0 &key)
void erase (iterator_0 first, iterator_0 last)
iterator_0 find (const key_type_0 &key)
const_iterator_0 find (const key_type_0 &key) const
iterator_0 find_particular (const key_type_0 &key)
const_iterator_0 find_particular (const key_type_0 &key) const
iterator_0 insert_nonunique (iterator_0 position, const value_type_0 &key)
iterator_0 insert_nonunique (const value_type_0 &key)
iterator_0 insert_unique (iterator_0 position, const value_type_0 &key)
pair< iterator_0, bool > insert_unique (const value_type_0 &key)
iterator_0 insert_unverified (iterator_0 position, const value_type_0 &key)
 Inserts the indicated key into the ordered vector at the indicated place.
iterator_0 lower_bound (const key_type_0 &key)
const_iterator_0 lower_bound (const key_type_0 &key) const
size_type_0 max_size () const
 Returns the maximum number of elements that can possibly be stored in an ordered vector.
bool operator!= (const ordered_vector< Key, Compare > &other) const
 Returns true if the two ordered vectors are not memberwise equivalent, false if they are.
bool operator< (const ordered_vector< Key, Compare > &other) const
 Returns true if this ordered vector sorts lexicographically before the other one, false otherwise.
bool operator<= (const ordered_vector< Key, Compare > &other) const
 Returns true if this ordered vector sorts lexicographically before the other one or is equivalent, false otherwise.
ordered_vector< Key, Compare > & operator= (const ordered_vector< Key, Compare > &copy)
bool operator== (const ordered_vector< Key, Compare > &other) const
 Returns true if the two ordered vectors are memberwise equivalent, false otherwise.
bool operator> (const ordered_vector< Key, Compare > &other) const
 Returns true if this ordered vector sorts lexicographically after the other one, false otherwise.
bool operator>= (const ordered_vector< Key, Compare > &other) const
 Returns true if this ordered vector sorts lexicographically after the other one or is equivalent, false otherwise.
reference operator[] (size_type_0 n)
const_reference operator[] (size_type_0 n) const
void pop_back ()
 Removes the last element at the end of the vector.
void push_back (const value_type_0 &key)
 Adds the new element to the end of the vector without regard for proper sorting.
reverse_iterator_0 rbegin ()
 Returns the iterator that marks the first element in the ordered vector, when viewed in reverse order.
const_reverse_iterator_0 rbegin () const
 Returns the iterator that marks the first element in the ordered vector, when viewed in reverse order.
reverse_iterator_0 rend ()
 Returns the iterator that marks the end of the ordered vector, when viewed in reverse order.
const_reverse_iterator_0 rend () const
 Returns the iterator that marks the end of the ordered vector, when viewed in reverse order.
void reserve (size_type_0 n)
 Informs the vector of a planned change in size; ensures that the capacity of the vector is greater than or equal to n.
size_type_0 size () const
 Returns the number of elements in the ordered vector.
void sort_nonunique ()
 Ensures that the vector is properly sorted after a potentially damaging operation.
void sort_unique ()
 Ensures that the vector is properly sorted after a potentially damaging operation.
void swap (ordered_vector< Key, Compare > &other)
 Exchanges the contents of this vector and the other vector, in constant time (e.g., with a pointer swap).
iterator_0 upper_bound (const key_type_0 &key)
const_iterator_0 upper_bound (const key_type_0 &key) const
bool verify_list_nonunique () const
bool verify_list_unique () const

Detailed Description

template<class Key, class Compare = less<Key>>
class ordered_vector< Key, Compare >

This template class presents an interface similar to the STL set or multiset (and ov_set and ov_multiset are implemented specifically, below), but it is implemented using a vector that is kept always in sorted order.

In most cases, an ov_set or ov_multiset may be dropped in transparently in place of a set or multiset, but the implementation difference has a few implications:

(1) The ov_multiset will maintain stability of order between elements that sort equally: they are stored in the order in which they were added, from back to front.

(2) Insert and erase operations into the middle of the set can be slow, just as inserting into the middle of a vector can be slow. In fact, building up an ov_set by inserting elements one at a time is an n^2 operation. On the other hand, building up an ov_set by adding elements to the end, one at time, is somewhat faster than building up a traditional set; and you can even add unsorted elements with push_back() and then call sort() when you're done, for a log(n) operation.

(3) Iterators may not be valid for the life of the ordered_vector. If the vector reallocates itself, all iterators are invalidated.

(4) Random access into the set is easy with the [] operator.

Definition at line 109 of file ordered_vector.h.


Member Function Documentation

template<class Key , class Compare >
ordered_vector< Key, Compare >::ITERATOR ordered_vector< Key, Compare >::begin ( ) [inline]

Returns the iterator that marks the first element in the ordered vector.

Definition at line 86 of file ordered_vector.I.

Referenced by AnimPreloadTable::add_anims_from(), RenderEffects::adjust_transform(), SpeedTreeNode::apply_attribs_to_vertices(), MayaNodeTree::clear_egg(), CharacterJoint::clear_local_transforms(), CharacterJoint::clear_net_transforms(), TransformBlend::compare_to(), OccluderEffect::compare_to_impl(), TexMatrixAttrib::compare_to_impl(), TextureAttrib::compare_to_impl(), LightAttrib::compare_to_impl(), ClipPlaneAttrib::compare_to_impl(), OccluderEffect::complete_pointers(), TransformBlend::complete_pointers(), ClipPlaneAttrib::complete_pointers(), TextureAttrib::complete_pointers(), RenderEffects::complete_pointers(), SpeedTreeNode::compute_internal_bounds(), SpeedTreeNode::count_total_instances(), TextureAttrib::cull_callback(), RenderEffects::cull_callback(), AsyncTaskManager::do_has_task(), AnimPreloadTable::find_anim(), RenderEffects::find_effect(), AttribNodeRegistry::find_node(), TextureAttrib::find_on_stage(), Multifile::find_subfile(), AsyncTaskManager::get_active_tasks(), TexMatrixAttrib::get_hash_impl(), TextureAttrib::get_hash_impl(), LightAttrib::get_hash_impl(), ClipPlaneAttrib::get_hash_impl(), CharacterJoint::get_local_transforms(), CharacterJoint::get_net_transforms(), SparseArray::get_next_higher_different_bit(), AsyncTaskManager::get_next_wake_time(), SparseArray::get_num_bits(), SparseArray::get_num_off_bits(), SparseArray::get_num_on_bits(), AsyncTaskManager::get_sleeping_tasks(), AsyncTaskManager::get_tasks(), TextureAttrib::has_cull_callback(), TransformBlend::limit_transforms(), VertexTransform::mark_modified(), TransformBlend::normalize_weights(), RenderEffects::operator<(), SpeedTreeNode::remove_all_trees(), GraphicsEngine::remove_all_windows(), AnimPreloadTable::remove_anim(), AttribNodeRegistry::remove_node(), Multifile::remove_subfile(), GraphicsEngine::remove_window(), GraphicsEngine::render_frame(), Multifile::repack(), GraphicsEngine::reset_all_windows(), MayaNodeTree::reset_sliders(), RenderEffects::safe_to_combine(), RenderEffects::safe_to_transform(), SpeedTreeNode::snap_to_terrain(), CharacterJoint::update_internals(), OccluderEffect::write_datagram(), AnimPreloadTable::write_datagram(), CharacterJoint::write_datagram(), TexMatrixAttrib::write_datagram(), TransformBlend::write_datagram(), ClipPlaneAttrib::write_datagram(), LightAttrib::write_datagram(), SparseArray::write_datagram(), TextureAttrib::write_datagram(), RenderEffects::write_datagram(), and SpeedTreeNode::write_datagram().

template<class Key , class Compare >
ordered_vector< Key, Compare >::CONST_ITERATOR ordered_vector< Key, Compare >::begin ( ) const [inline]

Returns the iterator that marks the first element in the ordered vector.

Definition at line 134 of file ordered_vector.I.

template<class Key , class Compare >
void ordered_vector< Key, Compare >::clear ( ) [inline]
template<class Key , class Compare >
ordered_vector< Key, Compare >::SIZE_TYPE ordered_vector< Key, Compare >::count ( const key_type_0 &  key) const [inline]

Returns the number of elements that sort equivalent to the key that are in the vector.

Definition at line 521 of file ordered_vector.I.

Referenced by CharacterJoint::has_local_transform(), and CharacterJoint::has_net_transform().

template<class Key , class Compare >
bool ordered_vector< Key, Compare >::empty ( ) const [inline]
template<class Key , class Compare >
ordered_vector< Key, Compare >::ITERATOR ordered_vector< Key, Compare >::end ( ) [inline]

Returns the iterator that marks the end of the ordered vector.

Definition at line 98 of file ordered_vector.I.

Referenced by AnimPreloadTable::add_anims_from(), SpeedTreeNode::add_tree(), RenderEffects::adjust_transform(), SpeedTreeNode::apply_attribs_to_vertices(), MayaNodeTree::clear_egg(), CharacterJoint::clear_local_transforms(), CharacterJoint::clear_net_transforms(), TransformBlend::compare_to(), OccluderEffect::compare_to_impl(), TexMatrixAttrib::compare_to_impl(), TextureAttrib::compare_to_impl(), LightAttrib::compare_to_impl(), ClipPlaneAttrib::compare_to_impl(), OccluderEffect::complete_pointers(), TransformBlend::complete_pointers(), ClipPlaneAttrib::complete_pointers(), TextureAttrib::complete_pointers(), SpeedTreeNode::compute_internal_bounds(), SpeedTreeNode::count_total_instances(), TextureAttrib::cull_callback(), RenderEffects::cull_callback(), AsyncTaskManager::do_find_task_chain(), AsyncTaskManager::do_has_task(), AnimPreloadTable::find_anim(), RenderEffects::find_effect(), AttribNodeRegistry::find_node(), TextureAttrib::find_on_stage(), Multifile::find_subfile(), AsyncTaskManager::get_active_tasks(), RenderEffects::get_effect(), TexMatrixAttrib::get_hash_impl(), TextureAttrib::get_hash_impl(), LightAttrib::get_hash_impl(), ClipPlaneAttrib::get_hash_impl(), SpeedTreeNode::get_instance_list(), CharacterJoint::get_local_transforms(), CharacterJoint::get_net_transforms(), SparseArray::get_next_higher_different_bit(), AsyncTaskManager::get_next_wake_time(), SparseArray::get_num_off_bits(), SparseArray::get_num_on_bits(), TextureAttrib::get_on_stage_override(), TextureAttrib::get_on_texture(), TexMatrixAttrib::get_override(), AsyncTaskManager::get_sleeping_tasks(), AsyncTaskManager::get_tasks(), TransformBlend::get_weight(), TextureAttrib::has_cull_callback(), Multifile::has_directory(), SpeedTreeNode::has_instance_list(), LightAttrib::has_off_light(), ClipPlaneAttrib::has_off_plane(), TextureAttrib::has_off_stage(), LightAttrib::has_on_light(), OccluderEffect::has_on_occluder(), ClipPlaneAttrib::has_on_plane(), TextureAttrib::has_on_stage(), TexMatrixAttrib::has_stage(), TransformBlend::has_transform(), TransformBlend::limit_transforms(), AttribNodeRegistry::lookup_node(), VertexTransform::mark_modified(), TransformBlend::normalize_weights(), RenderEffects::operator<(), SpeedTreeNode::remove_all_trees(), GraphicsEngine::remove_all_windows(), AttribNodeRegistry::remove_node(), AsyncTaskManager::remove_task_chain(), TransformBlend::remove_transform(), SpeedTreeNode::remove_tree(), GraphicsEngine::remove_window(), GraphicsEngine::render_frame(), Multifile::repack(), GraphicsEngine::reset_all_windows(), MayaNodeTree::reset_sliders(), RenderEffects::safe_to_combine(), RenderEffects::safe_to_transform(), Multifile::scan_directory(), VirtualFileSimple::scan_local_directory(), SpeedTreeNode::snap_to_terrain(), CharacterJoint::update_internals(), OccluderEffect::write_datagram(), AnimPreloadTable::write_datagram(), CharacterJoint::write_datagram(), TexMatrixAttrib::write_datagram(), TransformBlend::write_datagram(), ClipPlaneAttrib::write_datagram(), LightAttrib::write_datagram(), SparseArray::write_datagram(), TextureAttrib::write_datagram(), RenderEffects::write_datagram(), and SpeedTreeNode::write_datagram().

template<class Key , class Compare >
ordered_vector< Key, Compare >::CONST_ITERATOR ordered_vector< Key, Compare >::end ( ) const [inline]

Returns the iterator that marks the end of the ordered vector.

Definition at line 146 of file ordered_vector.I.

template<class Key, class Compare = less<Key>>
ordered_vector< Key, Compare >::ITERATOR ordered_vector< Key, Compare >::insert_unverified ( iterator_0  position,
const value_type_0 &  key 
) [inline]

Inserts the indicated key into the ordered vector at the indicated place.

The user is trusted to have already verified that this is the correct sorting position; no checks are made.

Definition at line 376 of file ordered_vector.I.

template<class Key , class Compare >
ordered_vector< Key, Compare >::SIZE_TYPE ordered_vector< Key, Compare >::max_size ( ) const [inline]

Returns the maximum number of elements that can possibly be stored in an ordered vector.

Definition at line 215 of file ordered_vector.I.

template<class Key, class Compare>
bool ordered_vector< Key, Compare >::operator!= ( const ordered_vector< Key, Compare > &  other) const [inline]

Returns true if the two ordered vectors are not memberwise equivalent, false if they are.

Definition at line 251 of file ordered_vector.I.

template<class Key, class Compare>
bool ordered_vector< Key, Compare >::operator< ( const ordered_vector< Key, Compare > &  other) const [inline]

Returns true if this ordered vector sorts lexicographically before the other one, false otherwise.

Definition at line 264 of file ordered_vector.I.

template<class Key, class Compare>
bool ordered_vector< Key, Compare >::operator<= ( const ordered_vector< Key, Compare > &  other) const [inline]

Returns true if this ordered vector sorts lexicographically before the other one or is equivalent, false otherwise.

Definition at line 290 of file ordered_vector.I.

template<class Key, class Compare>
bool ordered_vector< Key, Compare >::operator== ( const ordered_vector< Key, Compare > &  other) const [inline]

Returns true if the two ordered vectors are memberwise equivalent, false otherwise.

Definition at line 239 of file ordered_vector.I.

template<class Key, class Compare>
bool ordered_vector< Key, Compare >::operator> ( const ordered_vector< Key, Compare > &  other) const [inline]

Returns true if this ordered vector sorts lexicographically after the other one, false otherwise.

Definition at line 277 of file ordered_vector.I.

template<class Key, class Compare>
bool ordered_vector< Key, Compare >::operator>= ( const ordered_vector< Key, Compare > &  other) const [inline]

Returns true if this ordered vector sorts lexicographically after the other one or is equivalent, false otherwise.

Definition at line 303 of file ordered_vector.I.

template<class Key , class Compare >
void ordered_vector< Key, Compare >::pop_back ( ) [inline]

Removes the last element at the end of the vector.

Definition at line 692 of file ordered_vector.I.

Referenced by AsyncTaskManager::cleanup().

template<class Key , class Compare >
void ordered_vector< Key, Compare >::push_back ( const value_type_0 &  key) [inline]

Adds the new element to the end of the vector without regard for proper sorting.

This is a bad idea to do except to populate the vector the first time; be sure to call sort() after you have added all the elements.

Definition at line 680 of file ordered_vector.I.

Referenced by AnimPreloadTable::add_anim(), AnimPreloadTable::add_anims_from(), TextureAttrib::complete_pointers(), OccluderEffect::fillin(), AnimPreloadTable::fillin(), TexMatrixAttrib::fillin(), TransformBlend::fillin(), ClipPlaneAttrib::fillin(), TextureAttrib::fillin(), RenderEffects::fillin(), SpeedTreeNode::fillin(), LightAttrib::finalize(), SparseArray::read_datagram(), and GraphicsEngine::render_frame().

template<class Key , class Compare >
ordered_vector< Key, Compare >::REVERSE_ITERATOR ordered_vector< Key, Compare >::rbegin ( ) [inline]

Returns the iterator that marks the first element in the ordered vector, when viewed in reverse order.

Definition at line 110 of file ordered_vector.I.

Referenced by SparseArray::compare_to().

template<class Key , class Compare >
ordered_vector< Key, Compare >::CONST_REVERSE_ITERATOR ordered_vector< Key, Compare >::rbegin ( ) const [inline]

Returns the iterator that marks the first element in the ordered vector, when viewed in reverse order.

Definition at line 158 of file ordered_vector.I.

template<class Key , class Compare >
ordered_vector< Key, Compare >::REVERSE_ITERATOR ordered_vector< Key, Compare >::rend ( ) [inline]

Returns the iterator that marks the end of the ordered vector, when viewed in reverse order.

Definition at line 122 of file ordered_vector.I.

Referenced by SparseArray::compare_to().

template<class Key , class Compare >
ordered_vector< Key, Compare >::CONST_REVERSE_ITERATOR ordered_vector< Key, Compare >::rend ( ) const [inline]

Returns the iterator that marks the end of the ordered vector, when viewed in reverse order.

Definition at line 170 of file ordered_vector.I.

template<class Key, class Compare = less<Key>>
void ordered_vector< Key, Compare >::reserve ( size_type_0  n) [inline]
template<class Key , class Compare >
ordered_vector< Key, Compare >::SIZE_TYPE ordered_vector< Key, Compare >::size ( ) const [inline]

Returns the number of elements in the ordered vector.

Definition at line 203 of file ordered_vector.I.

Referenced by AnimPreloadTable::add_anims_from(), AsyncTaskManager::cleanup(), Multifile::compare_subfile(), TransformBlend::compare_to(), TexMatrixAttrib::complete_pointers(), TextureAttrib::complete_pointers(), RenderEffects::complete_pointers(), Multifile::extract_subfile(), Multifile::extract_subfile_to(), AnimPreloadTable::get_base_frame_rate(), AnimPreloadTable::get_basename(), MayaNodeTree::get_blend_desc(), RenderEffects::get_effect(), SparseArray::get_highest_off_bit(), SparseArray::get_highest_on_bit(), SpeedTreeNode::get_instance_list(), AttribNodeRegistry::get_node(), AttribNodeRegistry::get_node_name(), AttribNodeRegistry::get_node_type(), AnimPreloadTable::get_num_anims(), SparseArray::get_num_bits(), MayaNodeTree::get_num_blend_descs(), RenderEffects::get_num_effects(), AnimPreloadTable::get_num_frames(), AttribNodeRegistry::get_num_nodes(), LightAttrib::get_num_off_lights(), ClipPlaneAttrib::get_num_off_planes(), TextureAttrib::get_num_off_stages(), LightAttrib::get_num_on_lights(), OccluderEffect::get_num_on_occluders(), ClipPlaneAttrib::get_num_on_planes(), TexMatrixAttrib::get_num_stages(), Multifile::get_num_subfiles(), SparseArray::get_num_subranges(), AsyncTaskManager::get_num_task_chains(), TransformBlend::get_num_transforms(), SpeedTreeNode::get_num_trees(), GraphicsEngine::get_num_windows(), LightAttrib::get_off_light(), ClipPlaneAttrib::get_off_plane(), TextureAttrib::get_off_stage(), LightAttrib::get_on_light(), OccluderEffect::get_on_occluder(), ClipPlaneAttrib::get_on_plane(), TexMatrixAttrib::get_stage(), Multifile::get_subfile_internal_length(), Multifile::get_subfile_internal_start(), Multifile::get_subfile_length(), Multifile::get_subfile_name(), Multifile::get_subfile_timestamp(), SparseArray::get_subrange_begin(), SparseArray::get_subrange_end(), AsyncTaskManager::get_task_chain(), TransformBlend::get_transform(), SpeedTreeNode::get_tree(), TransformBlend::get_weight(), GraphicsEngine::get_window(), Multifile::is_subfile_compressed(), Multifile::is_subfile_encrypted(), Multifile::is_subfile_text(), TransformBlend::limit_transforms(), SpeedTreeNode::modify_tree(), Multifile::open_read_subfile(), AsyncTaskManager::poll(), Multifile::read_subfile(), AnimPreloadTable::remove_anim(), AttribNodeRegistry::remove_node(), Multifile::remove_subfile(), GraphicsEngine::render_frame(), TransformBlend::set_transform(), TransformBlend::set_weight(), AsyncTaskManager::start_threads(), AsyncTaskManager::stop_threads(), AsyncTaskManager::wait_for_tasks(), AnimPreloadTable::write_datagram(), CharacterJoint::write_datagram(), TexMatrixAttrib::write_datagram(), TransformBlend::write_datagram(), SparseArray::write_datagram(), RenderEffects::write_datagram(), and SpeedTreeNode::write_datagram().

template<class Key , class Compare >
void ordered_vector< Key, Compare >::sort_nonunique ( ) [inline]

Ensures that the vector is properly sorted after a potentially damaging operation.

This should not normally need to be called, unless the user has written to the vector using the non-const iterators or has called push_back().

Definition at line 665 of file ordered_vector.I.

Referenced by ov_multiset< Key, Compare >::sort().

template<class Key , class Compare >
void ordered_vector< Key, Compare >::sort_unique ( ) [inline]

Ensures that the vector is properly sorted after a potentially damaging operation.

This should not normally need to be called, unless the user has written to the vector using the non-const iterators or has called push_back().

This flavor of sort also eliminates repeated elements.

Definition at line 647 of file ordered_vector.I.

Referenced by ov_set< Key, Compare >::sort().

template<class Key, class Compare>
void ordered_vector< Key, Compare >::swap ( ordered_vector< Key, Compare > &  other) [inline]

Exchanges the contents of this vector and the other vector, in constant time (e.g., with a pointer swap).

Definition at line 614 of file ordered_vector.I.

Referenced by GraphicsEngine::remove_all_windows(), and GraphicsEngine::render_frame().


The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations