1 #ifndef ROSE_Tree_List_H
2 #define ROSE_Tree_List_H
3 #include <Rose/Tree/Base.h>
14 using EdgeVector = std::vector<std::unique_ptr<Edge<T>>>;
18 using Ptr = std::shared_ptr<List>;
44 typename EdgeVector::iterator base_;
46 iterator(
typename EdgeVector::iterator base)
108 return other.base_ - base_;
115 ASSERT_not_null(base_[n]);
121 ASSERT_not_null(*base_);
127 ASSERT_not_null(*base_);
141 return base_ == other.base_;
144 return base_ != other.base_;
147 return base_ < other.base_;
150 return base_ <= other.base_;
153 return base_ > other.base_;
156 return base_ >= other.base_;
169 return std::shared_ptr<List>(
new List);
176 return elmts_.empty();
183 return elmts_.size();
193 return elmts_.capacity();
201 elmts_.push_back(std::make_unique<
Edge<T>>(*
this, elmt));
202 return *elmts_.back();
209 ASSERT_forbid(elmts_.empty());
210 BasePtr retval = (*elmts_.back())();
219 return *elmts_.at(i);
222 return *elmts_.at(i);
225 return *elmts_.at(i);
228 return *elmts_.at(i);
244 ASSERT_forbid(elmts_.empty());
245 return *elmts_.front();
250 ASSERT_forbid(elmts_.empty());
251 return *elmts_.back();
256 if (i < elmts_.size()) {
257 return ChildDescriptor{i, boost::lexical_cast<std::string>(i), (*elmts_[i])()};
iterator & operator++()
Cause iterator to point to the next edge.
bool operator==(const iterator &other) const
Compare two iterators.
Random access iterator to non-const edges.
iterator & operator--()
Cause iterator to point to previous edge.
Edge< T > & push_back(const std::shared_ptr< T > &elmt)
Insert a child pointer at the end of this node.
iterator & operator=(const iterator &other)
Make this iterator point to the same element as the @ other iterator.
iterator begin()
Return an iterator pointing to the first edge.
difference_type operator-(const iterator &other) const
Distance between two iterators.
bool operator!=(const iterator &other) const
Compare two iterators.
Edge< T > & operator*()
Return a reference to the current edge.
const Edge< T > & at(size_t i) const
Return a reference to the Ith edge.
size_t size() const
Number of child edges.
bool operator<=(const iterator &other) const
Compare two iterators.
typename EdgeVector::size_type size_type
Size type.
Main namespace for the ROSE library.
iterator & operator-=(difference_type n)
Advance iterator in backward (or forward if negative) direction by n edges.
void reserve(size_t n)
Reserve space so the child edge vector can grow without being reallocated.
Edge< T > * operator->()
Return a pointer to the current edge.
std::shared_ptr< T > ChildPtr
Type of child pointer.
Edge< T > & front()
Return a reference to the first edge.
Information about a child.
Edge< T > & operator[](size_t i)
Return a reference to the Ith edge.
iterator operator--(int)
Cause iterator to point to previous edge.
iterator operator-(difference_type n) const
Advance iterator in backward (or forward if negative) direction by n edges.
Edge< T > & back()
Return a reference to the last edge.
iterator end()
Return an iterator pointing to one past the last edge.
iterator operator++(int)
Cause iterator to point to the next edge.
size_t capacity() const
Reserved capacity.
bool operator<(const iterator &other) const
Compare two iterators.
BasePtr pop_back()
Erase a child edge from the end of this node.
Edge< T > & operator[](difference_type n) const
Return an edge relative to the current one.
std::shared_ptr< Base > BasePtr
Shared-ownership pointer for Base.
A parent-to-child edge in a tree.
typename EdgeVector::difference_type difference_type
Distance between elements.
Tree vertex that points to an ordered sequence of indexable children.
iterator & operator+=(difference_type n)
Advance iterator in forward (or backward if negative) direction by n edges.
bool operator>(const iterator &other) const
Compare two iterators.
const Edge< T > & operator[](size_t i) const
Return a reference to the Ith edge.
bool empty() const
Test whether vector is empty.
Base class for tree vertices.
virtual ChildDescriptor findChild(size_t i) const override
Finds information about an indexed child.
iterator operator+(difference_type n) const
Advance iterator in forward (or backward if negative) direction by n edges.
static std::shared_ptr< List > instance()
Allocating constructor.
Edge< T > & at(size_t i)
Return a reference to the Ith edge.
BasePtr Ptr
Shared-ownership pointer to a Base.
bool operator>=(const iterator &other) const
Compare two iterators.