Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
xpath_node_set_raw Class Reference

Public Member Functions

 xpath_node_set_raw ()
xpath_node * begin () const
xpath_node * end () const
bool empty () const
size_t size () const
xpath_node first () const
void push_back_grow (const xpath_node &node, xpath_allocator *alloc)
void push_back (const xpath_node &node, xpath_allocator *alloc)
void append (const xpath_node *begin_, const xpath_node *end_, xpath_allocator *alloc)
void sort_do ()
void truncate (xpath_node *pos)
void remove_duplicates (xpath_allocator *alloc)
xpath_node_set::type_t type () const
void set_type (xpath_node_set::type_t value)

Detailed Description

Definition at line 9034 of file pugixml.cc.

Constructor & Destructor Documentation

◆ xpath_node_set_raw()

xpath_node_set_raw::xpath_node_set_raw ( )
inline

Definition at line 9043 of file pugixml.cc.

9043 : _type(xpath_node_set::type_unsorted), _begin(0), _end(0), _eos(0)
9044 {
9045 }

Member Function Documentation

◆ append()

void xpath_node_set_raw::append ( const xpath_node * begin_,
const xpath_node * end_,
xpath_allocator * alloc )
inline

Definition at line 9082 of file pugixml.cc.

9083 {
9084 if (begin_ == end_) return;
9085
9086 size_t size_ = static_cast<size_t>(_end - _begin);
9087 size_t capacity = static_cast<size_t>(_eos - _begin);
9088 size_t count = static_cast<size_t>(end_ - begin_);
9089
9090 if (size_ + count > capacity)
9091 {
9092 // reallocate the old array or allocate a new one
9093 xpath_node* data = static_cast<xpath_node*>(alloc->reallocate(_begin, capacity * sizeof(xpath_node), (size_ + count) * sizeof(xpath_node)));
9094 if (!data) return;
9095
9096 // finalize
9097 _begin = data;
9098 _end = data + size_;
9099 _eos = data + size_ + count;
9100 }
9101
9102 memcpy(_end, begin_, count * sizeof(xpath_node));
9103 _end += count;
9104 }
void * reallocate(void *ptr, size_t old_size, size_t new_size)
Definition pugixml.cc:7815

Referenced by xpath_ast_node::eval_node_set().

◆ begin()

xpath_node * xpath_node_set_raw::begin ( ) const
inline

Definition at line 9047 of file pugixml.cc.

9048 {
9049 return _begin;
9050 }

Referenced by xpath_ast_node::eval_node_set().

◆ empty()

bool xpath_node_set_raw::empty ( ) const
inline

Definition at line 9057 of file pugixml.cc.

9058 {
9059 return _begin == _end;
9060 }

Referenced by xpath_ast_node::eval_boolean().

◆ end()

xpath_node * xpath_node_set_raw::end ( ) const
inline

Definition at line 9052 of file pugixml.cc.

9053 {
9054 return _end;
9055 }

Referenced by xpath_ast_node::eval_node_set().

◆ first()

xpath_node xpath_node_set_raw::first ( ) const
inline

Definition at line 9067 of file pugixml.cc.

9068 {
9069 return xpath_first(_begin, _end, _type);
9070 }
PUGI__FN xpath_node xpath_first(const xpath_node *begin, const xpath_node *end, xpath_node_set::type_t type)
Definition pugixml.cc:9013

◆ push_back()

void xpath_node_set_raw::push_back ( const xpath_node & node,
xpath_allocator * alloc )
inline

Definition at line 9074 of file pugixml.cc.

9075 {
9076 if (_end != _eos)
9077 *_end++ = node;
9078 else
9079 push_back_grow(node, alloc);
9080 }
void push_back_grow(const xpath_node &node, xpath_allocator *alloc)
Definition pugixml.cc:9167

◆ push_back_grow()

PUGI__FN_NO_INLINE void xpath_node_set_raw::push_back_grow ( const xpath_node & node,
xpath_allocator * alloc )

Definition at line 9167 of file pugixml.cc.

9168 {
9169 size_t capacity = static_cast<size_t>(_eos - _begin);
9170
9171 // get new capacity (1.5x rule)
9172 size_t new_capacity = capacity + capacity / 2 + 1;
9173
9174 // reallocate the old array or allocate a new one
9175 xpath_node* data = static_cast<xpath_node*>(alloc->reallocate(_begin, capacity * sizeof(xpath_node), new_capacity * sizeof(xpath_node)));
9176 if (!data) return;
9177
9178 // finalize
9179 _begin = data;
9180 _end = data + capacity;
9181 _eos = data + new_capacity;
9182
9183 // push
9184 *_end++ = node;
9185 }

Referenced by push_back().

◆ remove_duplicates()

void xpath_node_set_raw::remove_duplicates ( xpath_allocator * alloc)
inline

Definition at line 9118 of file pugixml.cc.

9119 {
9120 if (_type == xpath_node_set::type_unsorted && _end - _begin > 2)
9121 {
9122 xpath_allocator_capture cr(alloc);
9123
9124 size_t size_ = static_cast<size_t>(_end - _begin);
9125
9126 size_t hash_size = 1;
9127 while (hash_size < size_ + size_ / 2) hash_size *= 2;
9128
9129 const void** hash_data = static_cast<const void**>(alloc->allocate(hash_size * sizeof(void**)));
9130 if (!hash_data) return;
9131
9132 memset(hash_data, 0, hash_size * sizeof(const void**));
9133
9134 xpath_node* write = _begin;
9135
9136 for (xpath_node* it = _begin; it != _end; ++it)
9137 {
9138 const void* attr = it->attribute().internal_object();
9139 const void* node = it->node().internal_object();
9140 const void* key = attr ? attr : node;
9141
9142 if (key && hash_insert(hash_data, hash_size, key))
9143 {
9144 *write++ = *it;
9145 }
9146 }
9147
9148 _end = write;
9149 }
9150 else
9151 {
9152 _end = unique(_begin, _end);
9153 }
9154 }
PUGI__FN I unique(I begin, I end)
Definition pugixml.cc:7592
PUGI__FN bool hash_insert(const void **table, size_t size, const void *key)
Definition pugixml.cc:7708
void * allocate(size_t size)
Definition pugixml.cc:7778

Referenced by xpath_ast_node::eval_node_set().

◆ set_type()

void xpath_node_set_raw::set_type ( xpath_node_set::type_t value)
inline

Definition at line 9161 of file pugixml.cc.

9162 {
9163 _type = value;
9164 }

Referenced by xpath_ast_node::eval_node_set().

◆ size()

size_t xpath_node_set_raw::size ( ) const
inline

Definition at line 9062 of file pugixml.cc.

9063 {
9064 return static_cast<size_t>(_end - _begin);
9065 }

◆ sort_do()

void xpath_node_set_raw::sort_do ( )
inline

Definition at line 9106 of file pugixml.cc.

9107 {
9108 _type = xpath_sort(_begin, _end, _type, false);
9109 }
PUGI__FN xpath_node_set::type_t xpath_sort(xpath_node *begin, xpath_node *end, xpath_node_set::type_t type, bool rev)
Definition pugixml.cc:8990

Referenced by xpath_ast_node::eval_node_set().

◆ truncate()

void xpath_node_set_raw::truncate ( xpath_node * pos)
inline

Definition at line 9111 of file pugixml.cc.

9112 {
9113 assert(_begin <= pos && pos <= _end);
9114
9115 _end = pos;
9116 }

◆ type()

xpath_node_set::type_t xpath_node_set_raw::type ( ) const
inline

Definition at line 9156 of file pugixml.cc.

9157 {
9158 return _type;
9159 }

Referenced by xpath_ast_node::eval_node_set().


The documentation for this class was generated from the following file: