1 #ifndef Rice__Array__hpp_
2 #define Rice__Array__hpp_
4 #include "Builtin_Object.hpp"
5 #include "to_from_ruby_defn.hpp"
6 #include "detail/ruby.hpp"
43 template<
typename Iter_T>
49 template<
typename T,
long n>
103 template<
typename Array_Ref_T,
typename Value_T>
106 long position_of(
long index)
const;
152 template<
typename Array_Ref_T,
typename Value_T>
153 class Array::Iterator
156 using iterator_category = std::forward_iterator_tag;
157 using value_type = Value_T;
158 using difference_type = long;
160 using reference = Value_T&;
162 Iterator(Array_Ref_T array,
long index);
164 template<
typename Array_Ref_T_,
typename Value_T_>
165 Iterator(Iterator<Array_Ref_T_, Value_T_>
const & rhs);
167 template<
typename Array_Ref_T_,
typename Value_T_>
168 Iterator & operator=(Iterator<Array_Ref_T_, Value_T_>
const & rhs);
170 Iterator & operator++();
171 Iterator operator++(
int);
175 template<
typename Array_Ref_T_,
typename Value_T_>
176 bool operator==(Iterator<Array_Ref_T_, Value_T_>
const & rhs)
const;
178 template<
typename Array_Ref_T_,
typename Value_T_>
179 bool operator!=(Iterator<Array_Ref_T_, Value_T_>
const & rhs)
const;
185 Array_Ref_T array()
const;
A helper class so array[index]=value can work.
Definition: Array.hpp:130
VALUE value() const
Explicit conversion to VALUE.
Object operator=(T const &value)
Assignment operator.
Proxy(Array array, long index)
Construct a new Proxy.
A wrapper for the ruby Array class.
Definition: Array.hpp:24
Array()
Construct a new array.
Array(Iter_T begin, Iter_T end)
Construct an array from a sequence.
Array(VALUE v)
Wrap an existing array.
long size() const
Return the size of the array.
iterator end()
Return an iterator to the end of the array.
Array(Object v)
Wrap an existing array.
Object unshift(T const &obj)
Unshift an element onto the beginning of the array.
Object operator[](long index) const
Return the element at the given index.
const_iterator begin() const
Return a const iterator to the beginning of the array.
const_iterator end() const
Return a const iterator to the end of the array.
Proxy operator[](long index)
Return a reference to the element at the given index.
iterator begin()
Return an iterator to the beginning of the array.
Object push(T const &obj)
Push an element onto the end of the array.
Object pop()
Pop an element from the end of the array.
Object shift()
Shift an element from the beginning of the array.
Iterator< Array const &, Object > const_iterator
A const iterator.
Definition: Array.hpp:113
Iterator< Array &, Proxy > iterator
An iterator.
Definition: Array.hpp:110
Array(T const (&a)[n])
Construct an Array from a C array.
A smartpointer-like wrapper for Ruby builtin objects.
Definition: Builtin_Object_defn.hpp:20
RObject & operator*() const
Return a reference to obj_.
Definition: Builtin_Object_defn.hpp:34
RObject * operator->() const
Return a pointer to obj_.
Definition: Builtin_Object_defn.hpp:35
The base class for all Objects.
Definition: Object_defn.hpp:25
Object(VALUE value=Qnil)
Encapsulate an existing ruby object.
Definition: Object_defn.hpp:28