Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nyuichi/ralist
Purely Functional Random-Access List on C++
https://github.com/nyuichi/ralist
Last synced: 20 days ago
JSON representation
Purely Functional Random-Access List on C++
- Host: GitHub
- URL: https://github.com/nyuichi/ralist
- Owner: nyuichi
- Created: 2012-09-09T15:41:44.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2012-09-09T15:47:13.000Z (over 12 years ago)
- Last Synced: 2024-10-16T03:48:12.833Z (2 months ago)
- Language: C++
- Size: 89.8 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.org
Awesome Lists containing this project
README
* Purely Functional Random-Access List
A straight port of Purely Functional Random-Access List by Chris Okasaki to C++.
Every method of RandomAccessList class doesn't check if the passed index is valid or not: you have to check it by hand before calling.
Likewise, every time taking the head or tail of a list you have to make sure that it is not empty.
Since this data structure is purely functional, all operations are done without chaning any part of the existing data.** HowToUse:
Just include ralist.h.** APIs:
- RandomAccessList() ::
constructor
- const RandomAccessList *cons(T x) const ::
Returns a newly allocated RandomAccessList. This operation takes O(1) time.
- T lookup(size_t i) const ::
Returns the value at i. Please verify i is in the range of the list before call. This operation takes O(logn) time.
- const RandomAccessList *update(size_t i, T y) const ::
Returns a list whose value at i has been replaced by y. This operation takes O(logn) time both in average and in the worst case.
- bool is_empty() const ::
Complexity: O(1).
- T head() const ::
Complexity: O(1).
- const RandomAccessList *tail() const ::
Complexity: O(1).