Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/from-nibly/cpplist
A linq like list in c++
https://github.com/from-nibly/cpplist
Last synced: 16 days ago
JSON representation
A linq like list in c++
- Host: GitHub
- URL: https://github.com/from-nibly/cpplist
- Owner: from-nibly
- Created: 2013-12-09T04:46:24.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2013-12-10T22:20:25.000Z (almost 11 years ago)
- Last Synced: 2024-07-31T22:58:44.067Z (3 months ago)
- Language: C
- Homepage:
- Size: 141 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
cpplist
=======This is a classic link list project. I really hate the lack of list like abilities in standard C++ so I wrote my own.
This project hides the node class and you never have to interact with it if you dont want to. Some list projects return the entire node rather than the value of the node. I feel this is cumbersome so I just return the value.
This project is starting out with the following functions:
void append(T)
This function will append one item of the initialized type to the end of the listvoid push(T);
This function will append one item of the initialized type to the begining of the listT pop();
This function will remove the first item in the list and return the value of it and return the value of itT serve();
This function is the same as pop (in fact it just calls it) this is so you can use the list as a queue while keeping the normal syntaxint getCount();
getCount returns the number of items in the list. This is incremented as you append or push so geting the count is in constant time.void traverse(void (*f) (T));
traverse simply takes a void (T) function and calls in using every item in the listvoid removeAt(int);
removeAt removes the item at the index givenfirst()
grabs the first item in the list. If there are no items in the list it will throw an exception.
last()
grabs the last item in the list
single()
grabs the first item in the list if there is more than one item in the list it will throw an exceptionsingleOrDefault(default)
grabs the first item in the list if there is more than one item in the list it will return default;where(predicate)
grabs all of the items when the predicate passed returns true. must be a --bool (*) (T)-- function.first(predicate)
grabs the first item of the sub list when the predicate passed returns true. Must be a --bool (*) (T)-- function.
calls this->where(pred)->first();
last(predicate)
grabs the last item of the sub list when the predicate passed returns true. Must be a --bool (*) (T)-- function.
calls this->where(pred)->last();
single(predicate)
grabs the first item of the sub list when the predicate passed returns true and throws an exception when the count of the list is not 1. The predicate must be a --bool (*) (T)-- function.
calls this->where(pred)->single();
singleOrDefault(predicate, default)
grabs the first item of the sub list when the predicate passed returns true and returns the default when the count of the list is not 1. The predicate must be a --bool (*) (T)-- function.
calls this->where(pred)->single();
getCount(predicate)
grabs the count of a sub list when the predicate passsed returns true. The predicate must be a --bool (*) (T)-- function.
returns this->where(pred)->getCount();
at()
grabs the item at the index. If the index is larger than the count it throws an exception;TODO:
orderBy(predicate)
at()
select()I also need to make some operator overloading
[] should be the same as at()
- bag type difference
| bag type intersection
& bag type union
+ bag type addition
<< traverse with [ , ] to create stream;