thxi / vec Goto Github PK
View Code? Open in Web Editor NEWAn implementation of vector in C.
License: MIT License
An implementation of vector in C.
License: MIT License
vec A simple vector implementation in C. Interface (thoroughly documented) can be found in include/vec/vec.h Core methods resemble the ones of https://en.cppreference.com/w/cpp/container/vector I made this to see CMake and C in action. INSTALL To use the library I recommend you not to use find_package. Instead use git submodules to checkout the repository and then add it to the project as a directory For example, suppose you have the following directory structure: ├── CMakeLists.txt ├── readme.txt └── src └── main.c - Checkout the repository as a submodule mkdir external && cd external && git submodule add [email protected]:thxi/vec.git && cd .. - Make a CMakeLists.txt in the external directory echo "add_subdirectory(vec)" > external/CmakeLists.txt - add the following lines to your main CMakeLists (which resides in the project root) add_subdirectory(vec) target_link_libraries(${YOUR_TARGET} vec) # do not forget to set the target - now you can use the lib USE After installing as described above: #include <stdio.h> #include <assert.h> #include "vec/vec.h" int main() { vec_type(int) v = vec_new(); for (int i = 0; i < 10; i++) { bool ret = vec_push(v, i + 1); if (ret != true) { return 1; // error allocating memory } } for_each(v) { printf("%d ", v.buf[i]); } printf("\n"); for (int i = 0; i < 5; i++) { vec_pop(v); } vec_shrink_to_fit(v); assert(v.size == 5); assert(v.cap == 5); for (int i = 0; i < 5; i++) { vec_pop(v); } assert(vec_empty(v) == true); vec_free(v); // do not forget to free } TODO: [X] implement core methods as in https://en.cppreference.com/w/cpp/container/vector [X] add sanitizer to test binary [X] add tests [X] add install [X] structure tests [ ] add example to a different directory
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.