Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement some #17

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion example/array.usage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using namespace std;

int main() {
Array a (10);
Array<int> a (10);

for (int i = 0; i < 1000; ++i) a[i] = i;

Expand Down
18 changes: 17 additions & 1 deletion lib/array.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class Array {
return slice[index_in_slice];
};


public:
int length;

Expand Down Expand Up @@ -136,6 +136,22 @@ class Array {
};


// Check, whether array contains
// appropriate element
// fn - function, which returns
// true or false
//
bool some(bool (*fn)(T)) {
for (int i = 0; i < this->length; ++i) {
T item = this->get(i);
bool some = fn(item);
if (some) return 1;
}

return 0;
};


// Create string from elements of array
// separated by specified separator
//
Expand Down