Giter Site home page Giter Site logo

datastructures's Issues

Vector class

We should implement a vector class, using std:vector from C++, which would allow adding new items to a vector with amortized constant complexity (it would solve a "dynamically extending vector" problem).

The main question is: should it be a vector of any R objects (it would be like an R list), or maybe one type of objects (more like an R vector)?

And is there any way to implement operator [], like vector[5]? Or the only way is to make a function get_element(vector, 5) and set_element(vector, 5)?

Nice interface by classes

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).

stack, queue: add as.list

It'd be lovely if we were able to convert a stack or a queue to an R list object

so we need

as.list.stack and as.list.queue

moreover, queue/list constructor should mark class of retval to queue/stack
print.stack, print.queue and maybe format.stack and format.queue should be defined

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.