Skip to content

An original deque data structure that answers in amortized O(f) time the result of applying f() to the elements in the deque, implemented in C++.

License

Notifications You must be signed in to change notification settings

juanigsrz/op_deque

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

op_deque

An enhanced deque data structure, implemented on C++. This deque is capable of answering, in O(F) amortized time, the result of applying some function F to all the elements in the deque.

Use

First, include the op_deque with #include "op_deque.cpp"

To instantiate a new op_deque, use op_deque<T, F> Name;

  • T is the type of the elements in the deque
  • F is a commutative and associative functor with arity 2
  • Name is the name of your instance.

Basic methods

Method name Description
size() get the number of elements
[i] get the element at the i-th index
pop_front() pop the element at the front
pop_back() pop the element at the back
push_front(x) push a new element x at the front
push_back(x) push a new element x at the back
front() get the element at the front
back() get the element at the back

Special methods

Method name Description
get() get, in O(F) amortized time, the result of applying F to the whole deque

To do:

  • Study and modify the order of operations to relax the commutative functor requirement
  • Replace rastack<T> with vector<T>
  • Improve the asymptotic constant by optimizing balance()
  • Formal proof
  • Proper testing and documentation

About

An original deque data structure that answers in amortized O(f) time the result of applying f() to the elements in the deque, implemented in C++.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages