1 #ifndef Rice__Hash__hpp_
2 #define Rice__Hash__hpp_
4 #include "Builtin_Object_defn.hpp"
6 #include "to_from_ruby_defn.hpp"
7 #include "detail/ruby.hpp"
48 template<
typename Key_T>
55 template<
typename Key_T>
64 template<
typename Value_T,
typename Key_T>
65 Value_T
get(Key_T
const & key);
71 template<
typename Hash_Ref_T,
typename Value_T>
112 void swap(
Proxy & proxy);
139 void swap(
Entry & entry);
141 friend bool operator<(
Entry const & lhs,
Entry const & rhs);
147 template<
typename Hash_Ref_T,
typename Value_T>
151 using iterator_category = std::input_iterator_tag;
152 using value_type = Value_T;
153 using difference_type = long;
155 using reference = Value_T&;
168 template<
typename Iterator_T>
192 template<
typename Hash_Ref_T_,
typename Value_T_>
205 size_t current_index_;
208 mutable typename std::remove_const<Value_T>::type tmp_;
A wrapper for the ruby Array class.
Definition: Array.hpp:24
A smartpointer-like wrapper for Ruby builtin objects.
Definition: Builtin_Object_defn.hpp:20
A helper class for dereferencing iterators.
Definition: Hash.hpp:123
Object const key
The key.
Definition: Hash.hpp:131
Proxy value
The value.
Definition: Hash.hpp:134
Entry(Entry const &entry)
Copy constructor.
Proxy & second
An alias for the value.
Definition: Hash.hpp:135
Object const & first
An alias for the key.
Definition: Hash.hpp:132
Entry(Hash hash, Object key)
Construct a new Entry.
A helper class for implementing iterators for a Hash.
Definition: Hash.hpp:149
Iterator & operator++()
Preincrement operator.
Iterator(Hash_Ref_T hash, int start_at)
Construct a new Iterator with a given start-at index point.
Iterator(Iterator_T const &iterator)
Iterator(Hash_Ref_T hash)
Construct a new Iterator.
Value_T * operator->()
Dereference operator.
Iterator & operator=(Iterator const &rhs)
Assignment operator.
Iterator operator++(int)
Postincrement operator.
bool operator!=(Iterator const &rhs) const
Inequality operator.
Value_T operator*()
Dereference operator.
void swap(Iterator &iterator)
Swap with another iterator of the same type.
bool operator==(Iterator const &rhs) const
Equality operator.
Iterator(Iterator const &iterator)
Copy construct an Iterator.
A helper class so hash[key]=value can work.
Definition: Hash.hpp:97
Object operator=(T const &value)
Assignment operator.
Proxy(Hash hash, Object key)
Construct a new Proxy.
VALUE value() const
Explicit conversion to VALUE.
size_t size() const
Return the number of elements in the hash.
Value_T get(Key_T const &key)
Get the value for the given key.
Hash(Object v)
Wrap an existing hash.
Iterator< Hash &, Entry > iterator
An iterator.
Definition: Hash.hpp:72
iterator end()
Return an iterator to the end of the hash.
Proxy const operator[](Key_T const &key) const
Get the value for the given key.
iterator begin()
Return an iterator to the beginning of the hash.
Iterator< Hash const &, Entry const > const_iterator
A const iterator.
Definition: Hash.hpp:79
Hash()
Construct a new hash.
const_iterator end() const
Return a const to the end of the hash.
Proxy operator[](Key_T const &key)
Get the value for the given key.
const_iterator begin() const
Return a const iterator to the beginning of the hash.
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