From de498e1649d1f57d4d79f81f47157ee3513ce122 Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Thu, 31 Dec 2020 12:31:31 +0100 Subject: Added links to documentation of similar C++ classes. --- README.md | 10 ++++++---- docs/carray_api.md | 1 + docs/cbitset_api.md | 3 ++- docs/cdeq_api.md | 5 +++-- docs/clist_api.md | 5 +++-- docs/cmap_api.md | 1 + docs/copt_api.md | 5 +++-- docs/cpque_api.md | 3 ++- docs/cptr_api.md | 6 ++++-- docs/cqueue_api.md | 1 + docs/crand_api.md | 3 ++- docs/cset_api.md | 4 ++-- docs/cstack_api.md | 3 ++- docs/cstr_api.md | 1 + docs/cvec_api.md | 1 + 15 files changed, 34 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index fdad4c66..e96c5b85 100644 --- a/README.md +++ b/README.md @@ -4,10 +4,11 @@ STC - Standard Template Containers for C Introduction ------------ -An modern, fully typesafe, generic, customizable, user-friendly, consistent, and very fast standard container library for C99. This is a small headers only library with the most used container components, and a few algorithms: +An modern, fully typesafe, generic, customizable, user-friendly, consistent, and very fast standard container library for C99. +This is a small headers only library with the most used container components, and a few algorithms: - [***cstr*** - A **std::string** alike type](docs/cstr_api.md) - [***cvec*** - Templated **std::vector** alike type](docs/cvec_api.md) -- [***cdeq*** - Templated **std::dequeue** alike type](docs/cdeq_api.md) +- [***cdeq*** - Templated **std::deque** alike type](docs/cdeq_api.md) - [***cmap*** - Templated **std::unordered_map** alike type](docs/cmap_api.md) - [***cset*** - Templated **std::unordered_set** alike type](docs/cset_api.md) - [***cstack*** - Templated **std::stack** alike adapter type](docs/cstack_api.md) @@ -23,7 +24,8 @@ An modern, fully typesafe, generic, customizable, user-friendly, consistent, and The usage of the containers is similar to the C++ standard containers, so it should be easy if you are familiar with them. -All containers mentioned above, except cstr_t and cbitset_t, are generic and therefore typesafe (similar to templates in C++). No casting is used. A simple example: +All containers mentioned above, except cstr_t and cbitset_t, are generic and therefore typesafe (similar to templates in C++). +No casting is used. A simple example: ```c #include @@ -38,7 +40,7 @@ int main(void) { cvec_i_del(&vec); } ``` -Containers with struct element types: +Container with elements of structs: ```c #include #include diff --git a/docs/carray_api.md b/docs/carray_api.md index 248c67c1..dfe27066 100644 --- a/docs/carray_api.md +++ b/docs/carray_api.md @@ -2,6 +2,7 @@ This is 1D, 2D and 3D arrays, which are allocated from heap in one single contiguous block of memory. *carray3* may have sub-array "views" of *carray2* and *carray1* etc. +See [boost::multi_array](https://www.boost.org/doc/libs/release/libs/multi_array) for similar c++ classes. ## Declaration diff --git a/docs/cbitset_api.md b/docs/cbitset_api.md index a9d7d583..43f45ae0 100644 --- a/docs/cbitset_api.md +++ b/docs/cbitset_api.md @@ -1,6 +1,7 @@ # Container [cbitset](../stc/cbitset.h): Indexed Bitset -This describes the API of type **cbitset**. +This describes the API of type **cbitset**. See [std::bitset](https://en.cppreference.com/w/cpp/utility/bitset) or +[boost::dynamic_bitset](https://www.boost.org/doc/libs/release/libs/dynamic_bitset/dynamic_bitset.html) for similar c++ classes. ## Types diff --git a/docs/cdeq_api.md b/docs/cdeq_api.md index 746b585a..47a3fba9 100644 --- a/docs/cdeq_api.md +++ b/docs/cdeq_api.md @@ -1,6 +1,7 @@ -# Container [cdeq](../stc/cdeq.h): Deque (Double Ended Queue) +# Container [cdeq](../stc/cdeq.h): Double Ended Queue (Deque) -This describes the API of vector type **cdeq**. +This describes the API of deque type **cdeq**. +See [std::deque](https://en.cppreference.com/w/cpp/container/deque) for corresponding c++ documentation. ## Declaration diff --git a/docs/clist_api.md b/docs/clist_api.md index e305ed48..4958bc04 100644 --- a/docs/clist_api.md +++ b/docs/clist_api.md @@ -1,7 +1,8 @@ # Container [clist](../stc/clist.h): Singly Linked List -This is similar to c++ *std::forward_list*, but can do both *push_front()* and *push_back()* as well as *pop_front()*. -Implemented as a circular singly linked list. Also supports various *splice* functions and *merge sort*. +This is similar to c++ [std::forward_list](https://en.cppreference.com/w/cpp/container/forward_list), but supports both +*push_front()* and *push_back()* as well as *pop_front()*. Implemented as a circular singly linked list. Also supports various +*splice* functions and *merge sort*. ## Declaration diff --git a/docs/cmap_api.md b/docs/cmap_api.md index 322a4104..9e65a69e 100644 --- a/docs/cmap_api.md +++ b/docs/cmap_api.md @@ -1,6 +1,7 @@ # Container [cmap](../stc/cmap.h): Unordered Map Elements are pairs of keys and mapped values. Implemented as open hashing without tombstones. Highly customizable and fast. +See [std::unordered_map](https://en.cppreference.com/w/cpp/container/unordered_map) for a similar c++ class. ## Declaration diff --git a/docs/copt_api.md b/docs/copt_api.md index 2ced17ce..1973cec5 100644 --- a/docs/copt_api.md +++ b/docs/copt_api.md @@ -1,6 +1,7 @@ # Module [copt](../stc/copt.h): Command line argument parsing This describes the API of string type *copt_get()* function for command line argument parsing. +See [getopt_long](https://www.freebsd.org/cgi/man.cgi?getopt_long(3)) for a similar freebsd function. ## Types @@ -16,7 +17,7 @@ typedef struct { const char *arg; /* equivalent to optarg */ const char *faulty; /* points to the faulty option, if any */ int longindex; /* index of long option; or -1 if short */ - ... + ... } copt_t; typedef struct { @@ -45,7 +46,7 @@ int copt_get(copt_t *opt, int argc, char *argv[], int main(int argc, char *argv[]) { static copt_long_t long_options[] = { {"verbose", copt_no_argument, 'V'}, - {"help", copt_no_argument, 'H'}, + {"help", copt_no_argument, 'H'}, {"add", copt_no_argument, 'a'}, {"append", copt_no_argument, 'b'}, {"delete", copt_required_argument, 'd'}, diff --git a/docs/cpque_api.md b/docs/cpque_api.md index 7e0021d3..9fc0c7e1 100644 --- a/docs/cpque_api.md +++ b/docs/cpque_api.md @@ -1,6 +1,7 @@ # Container [cpque](../stc/cpque.h): Priority Queue -This describes the API of the queue type **cpque**. Implemented as a heap. +This describes the API of the priority queue type **cpque**. Implemented as a heap. +See [std::priority_queue](https://en.cppreference.com/w/cpp/container/priority_queue) for a similar c++ class. ## Declaration diff --git a/docs/cptr_api.md b/docs/cptr_api.md index 2d626fa8..30055f00 100644 --- a/docs/cptr_api.md +++ b/docs/cptr_api.md @@ -1,6 +1,8 @@ # Module [cptr](../stc/cptr.h): Smart Pointers -This describes the API of the pointer type **cptr** and the shared pointer type **csptr**. Type **cptr** is meant to be used like a c++ *std::unique_ptr*, while **csptr** is similar to c++ *std::shared_ptr*. +This describes the API of the pointer type **cptr** and the shared pointer type **csptr**. Type **cptr** can be used similar to a c++ +[std::unique_ptr](https://en.cppreference.com/w/cpp/memory/unique_ptr), while **csptr** is similar to a c++ +[std::shared_ptr](https://en.cppreference.com/w/cpp/memory/shared_ptr). **cptr** and **csptr** objects can be used as items of containers. The pointed-to elements are automatically destructed+deleted when the container is destructed. **csptr** elements are only deleted if there are no other shared references to the element. **csptr** has thread-safe atomic use count, enabled by the *csptr_X_share(sp)* and *csptr_X_del(&sp)* methods. @@ -109,7 +111,7 @@ int main() { cvec_ps_sort(&svec); c_foreach (i, cvec_ps, svec) printf(" %s %s\n", i.ref->get->name.str, i.ref->get->last.str); - + csptr_ps x = csptr_ps_share(svec.data[1]); puts("\nDestroy svec:"); diff --git a/docs/cqueue_api.md b/docs/cqueue_api.md index 4645cbeb..8a6edd2b 100644 --- a/docs/cqueue_api.md +++ b/docs/cqueue_api.md @@ -1,6 +1,7 @@ # Container [cqueue](../stc/cqueue.h): Queue This describes the API of the queue type **cqueue**. +See [std::queue](https://en.cppreference.com/w/cpp/container/queue) for a similar c++ class. ## Declaration diff --git a/docs/crand_api.md b/docs/crand_api.md index 3299b046..4678cbd3 100644 --- a/docs/crand_api.md +++ b/docs/crand_api.md @@ -1,7 +1,8 @@ # Module [crand](../stc/crand.h): Pseudo Random Number Generators This describes the API of module **crand**. It contains **stc64**, a *64-bit PRNG*, and can generate -bounded uniform and normal distributed random numbers. +bounded uniform and normal distributed random numbers. See [random](https://en.cppreference.com/w/cpp/header/random) +for similar c++ functionality. **stc64** is an extremely fast PRNG by Tyge Løvset, suited for parallel usage. It features a Weyl-sequence as part of the state. It is faster than *sfc64*, *wyhash64*, *pcg64*, and *xoshiro256\*\** diff --git a/docs/cset_api.md b/docs/cset_api.md index ef87bef7..999edd4c 100644 --- a/docs/cset_api.md +++ b/docs/cset_api.md @@ -1,7 +1,7 @@ # Container [cset](../stc/cmap.h): Unordered Set -This describes the API of the unordered set type **cset**. -Same base implementation as cmap, but contains and uses keys only. +This describes the API of the unordered set type **cset**. Same base implementation as cmap, but contains and uses keys only. +See [std::unordered_set](https://en.cppreference.com/w/cpp/container/unordered_set) for a similar c++ class. ## Declaration diff --git a/docs/cstack_api.md b/docs/cstack_api.md index bf707d83..7f0c1636 100644 --- a/docs/cstack_api.md +++ b/docs/cstack_api.md @@ -1,6 +1,7 @@ # Container [cstack](../stc/cstack.h): Stack -This describes the API of the queue type **cstack**. +This describes the API of the stack type **cstack**. +See [std::stack](https://en.cppreference.com/w/cpp/container/stack) for a similar c++ class. ## Declaration diff --git a/docs/cstr_api.md b/docs/cstr_api.md index 7a86ecc8..912d66a5 100644 --- a/docs/cstr_api.md +++ b/docs/cstr_api.md @@ -1,6 +1,7 @@ # Container [cstr](../stc/cstr.h): String This describes the API of string type **cstr_t**. +See [std::basic_string](https://en.cppreference.com/w/cpp/string/basic_string) for a similar c++ class. ## Types diff --git a/docs/cvec_api.md b/docs/cvec_api.md index 3afe7581..b3253935 100644 --- a/docs/cvec_api.md +++ b/docs/cvec_api.md @@ -1,6 +1,7 @@ # Container [cvec](../stc/cvec.h): Vector This describes the API of vector type **cvec**. +See [std::vector](https://en.cppreference.com/w/cpp/container/vector) for a similar c++ class. ## Declaration -- cgit v1.2.3