| 6802 | } |
| 6803 | |
| 6804 | class xpath_node_set_raw |
| 6805 | { |
| 6806 | xpath_node_set::type_t _type; |
| 6807 | |
| 6808 | xpath_node* _begin; |
| 6809 | xpath_node* _end; |
| 6810 | xpath_node* _eos; |
| 6811 | |
| 6812 | public: |
| 6813 | xpath_node_set_raw(): _type(xpath_node_set::type_unsorted), _begin(0), _end(0), _eos(0) |
| 6814 | { |
| 6815 | } |
| 6816 | |
| 6817 | xpath_node* begin() const |
| 6818 | { |
| 6819 | return _begin; |
| 6820 | } |
| 6821 | |
| 6822 | xpath_node* end() const |
| 6823 | { |
| 6824 | return _end; |
| 6825 | } |
| 6826 | |
| 6827 | bool empty() const |
| 6828 | { |
| 6829 | return _begin == _end; |
| 6830 | } |
| 6831 | |
| 6832 | size_t size() const |
| 6833 | { |
| 6834 | return static_cast<size_t>(_end - _begin); |
| 6835 | } |
| 6836 | |
| 6837 | xpath_node first() const |
| 6838 | { |
| 6839 | return xpath_first(_begin, _end, _type); |
| 6840 | } |
| 6841 | |
| 6842 | void push_back(const xpath_node& node, xpath_allocator* alloc) |
| 6843 | { |
| 6844 | if (_end == _eos) |
| 6845 | { |
| 6846 | size_t capacity = static_cast<size_t>(_eos - _begin); |
| 6847 | |
| 6848 | // get new capacity (1.5x rule) |
| 6849 | size_t new_capacity = capacity + capacity / 2 + 1; |
| 6850 | |
| 6851 | // reallocate the old array or allocate a new one |
| 6852 | xpath_node* data = static_cast<xpath_node*>(alloc->reallocate(_begin, capacity * sizeof(xpath_node), new_capacity * sizeof(xpath_node))); |
| 6853 | assert(data); |
| 6854 | |
| 6855 | // finalize |
| 6856 | _begin = data; |
| 6857 | _end = data + capacity; |
| 6858 | _eos = data + new_capacity; |
| 6859 | } |
| 6860 | |
| 6861 | *_end++ = node; |