Added value_t::push_front

This commit is contained in:
John Wiegley 2009-11-04 20:07:44 -05:00
parent b14c814fec
commit 4a14f3224b
3 changed files with 13 additions and 1 deletions

View file

@ -190,6 +190,7 @@ public:
virtual value_t operator()(call_scope_t& args) {
if (! args.empty()) {
args.push_front(string_value("?expr"));
return handler_wrapper(args);
}
else if (wants_arg) {

View file

@ -196,6 +196,9 @@ public:
return args[index];
}
void push_front(const value_t& val) {
args.push_front(val);
}
void push_back(const value_t& val) {
args.push_back(val);
}

View file

@ -87,7 +87,7 @@ public:
* The sequence_t member type abstracts the type used to represent a
* resizable "array" of value_t objects.
*/
typedef std::vector<value_t> sequence_t;
typedef std::deque<value_t> sequence_t;
typedef sequence_t::iterator iterator;
typedef sequence_t::const_iterator const_iterator;
typedef sequence_t::difference_type difference_type;
@ -800,6 +800,14 @@ public:
return null;
}
void push_front(const value_t& val) {
if (is_null())
*this = sequence_t();
if (! is_sequence())
in_place_cast(SEQUENCE);
as_sequence_lval().push_front(val);
}
void push_back(const value_t& val) {
if (is_null())
*this = sequence_t();