Open bartoszukm opened 9 years ago
I think it would be nice to have something more convenient than bunch of methods like vector_push_back() or queue_pop(), where external pointer is needed as an argument. More readable would be something like vector.push_back(6).
And my proposition is like that:
dsVector <- setRefClass("Vector", fields=c("vec" ), methods = list( initialize=function(n=0) { vec <<- vector_create(n) }, push_back=function(obj) { vector_push_back(vec, obj) }, back=function(obj) { vector_back(vec) }, front=function(obj) { vector_front(vec) }, size=function() { vector_size(vec) } ))
and usage;
vec2 <- dsVector$new(5) vec2$size() vec2$push_back(1) vec2$front() vec2$back()
My only concern is how to make indexer, like "vec2[3] = 5", but I think it is possible in one way or another.
OK, maybe another concern: how to do something like as.character(vector) or print(vector).
I think it would be nice to have something more convenient than bunch of methods like vector_push_back() or queue_pop(), where external pointer is needed as an argument. More readable would be something like vector.push_back(6).
And my proposition is like that:
and usage;
My only concern is how to make indexer, like "vec2[3] = 5", but I think it is possible in one way or another.
OK, maybe another concern: how to do something like as.character(vector) or print(vector).