Skip to content

Commit 9a55b98

Browse files
committed
Improve appearence of README.
1 parent aa7b89c commit 9a55b98

File tree

2 files changed

+8
-17
lines changed

2 files changed

+8
-17
lines changed

README.md

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,9 @@ To generate implementations, define `ARRAY_ALG_IMPLEMENTATION` in a C file and i
3636
#define ARRAY_ALG_IMPLEMENTATION
3737
#include "array_alg.h"
3838

39-
Alternatively, you can include the algorithms as static functions to avoid the need for separate implementations:
4039

41-
#define ARRAY_ALG_STATIC
42-
#define ARRAY_ALG_TYPE int
43-
#define ARRAY_ALG_PREFIX intv_
44-
#define ARRAY_ALG_IMPLEMENTATION
45-
#include "array_alg.h"
40+
Alternatively, add `#define ARRAY_ALG_STATIC` before the original declaration
41+
to avoid the need for separate implementations.
4642

4743
Repeat this process for each array type you want to use.
4844

@@ -67,7 +63,7 @@ Remove duplicate entries:
6763

6864
## Design
6965

70-
1. Iterators and Arrays
66+
### 1. Iterators and Arrays
7167

7268
The C++ STL is designed around the concept of iterators.
7369
With iterators, one algorithm can be reused not just for multiple types, but also for many data structures.
@@ -79,7 +75,7 @@ For those cases where you do have a fancy data structure (graphs, trees, etc),
7975
copy its contents to an array, perform the algorithm, and then copy the contents back.
8076
This will often help it perform better anyway!
8177

82-
2. Bounds vs counted ranges
78+
### 2. Bounds vs counted ranges
8379

8480
STL algorithms typically operate on half-open ranges bounded by iterators [first, last).
8581
This convention is not used as often in C, but we think it offers some benefits.
@@ -90,7 +86,7 @@ Operations also compose a little easier.
9086
When a pointer is returned to an element of interest,
9187
that same pointer can be used as an argument for another algorithm.
9288

93-
3. What's left out
89+
### 3. What's left out
9490

9591
Because it's a bit verbose to define a C closure (function pointer and context), some STL algorithms are less useful in C.
9692
If an algorithm can be written as a simple for loop with no additional state or control flow, this library doesn't implement it.
@@ -103,7 +99,7 @@ If an algorithm can be written as a simple for loop with no additional state or
10399
The algorithms which rely on ordered types always require a comparison function.
104100
We do not include any variants that operate on the `==` operator, as operators cannot be overloaded in C.
105101

106-
4. Generics vs `void*`
102+
### 4. Generics vs `void*`
107103

108104
Including a header multiple times with various `#define`s is a little cumbersome.
109105
However, we think it's a superior way to achieve C generics compared to the `void*` style used by `qsort` and `bsearch`.

array_alg.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,8 @@ To generate implementations, define `ARRAY_ALG_IMPLEMENTATION` in a C file and i
3939
#define ARRAY_ALG_IMPLEMENTATION
4040
#include "array_alg.h"
4141
42-
Alternatively, you can include the algorithms as static functions to avoid the need for separate implementations:
43-
44-
#define ARRAY_ALG_STATIC
45-
#define ARRAY_ALG_TYPE int
46-
#define ARRAY_ALG_PREFIX intv_
47-
#define ARRAY_ALG_IMPLEMENTATION
48-
#include "array_alg.h"
42+
Alternatively, add `#define ARRAY_ALG_STATIC` before the original declaration
43+
to avoid the need for separate implementations.
4944
5045
Repeat this process for each array type you want to use.
5146

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy