docs/Writerside/topics/utils.md

Sun, 23 Nov 2025 13:15:19 +0100

author
Mike Becker <universe@uap-core.de>
date
Sun, 23 Nov 2025 13:15:19 +0100
changeset 1508
dfc0ddd9571e
parent 1424
563033aa998c
permissions
-rw-r--r--

optimize sorted insertion by using the infimum instead of the supremum

The reason is that the supremum returns the equal element with the smallest index, and we want the largest.
Therefore, we use the infimum, which already gives us the largest index when there are equal elements, and increase the index by one. The infimum is also guaranteed to exist in that case.

1141
a06a2d27c043 create new page structure
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1 # Utilities
1166
03bbdf402675 write introduction for the Utilities Section
Mike Becker <universe@uap-core.de>
parents: 1141
diff changeset
2
03bbdf402675 write introduction for the Utilities Section
Mike Becker <universe@uap-core.de>
parents: 1141
diff changeset
3 Useful functions that are not specifically tied to a certain topic or domain are called Utilities.
03bbdf402675 write introduction for the Utilities Section
Mike Becker <universe@uap-core.de>
parents: 1141
diff changeset
4 The most useful of which are the predefined [compare functions](compare.h.md) for various primitive types.
03bbdf402675 write introduction for the Utilities Section
Mike Becker <universe@uap-core.de>
parents: 1141
diff changeset
5
03bbdf402675 write introduction for the Utilities Section
Mike Becker <universe@uap-core.de>
parents: 1141
diff changeset
6 The [hash functions](hash_key.h.md) are usually of lesser interest unless you are using [hash maps](hash_map.h.md),
03bbdf402675 write introduction for the Utilities Section
Mike Becker <universe@uap-core.de>
parents: 1141
diff changeset
7 but they can be also used independently of the hash map context.
03bbdf402675 write introduction for the Utilities Section
Mike Becker <universe@uap-core.de>
parents: 1141
diff changeset
8
03bbdf402675 write introduction for the Utilities Section
Mike Becker <universe@uap-core.de>
parents: 1141
diff changeset
9 When you are working with [data streams](streams.h.md), e.g. `FILE` streams
03bbdf402675 write introduction for the Utilities Section
Mike Becker <universe@uap-core.de>
parents: 1141
diff changeset
10 or any other stream (or buffer) API that uses an `fwrite`-compatible interface,
03bbdf402675 write introduction for the Utilities Section
Mike Becker <universe@uap-core.de>
parents: 1141
diff changeset
11 you will find the stream copy function quite useful.
03bbdf402675 write introduction for the Utilities Section
Mike Becker <universe@uap-core.de>
parents: 1141
diff changeset
12
1424
563033aa998c fixes tons of typos and grammar issues across the documentation - fixes #667
Mike Becker <universe@uap-core.de>
parents: 1166
diff changeset
13 And last, but not least, if you are interested in unit testing but don't know which testing framework to use:
1166
03bbdf402675 write introduction for the Utilities Section
Mike Becker <universe@uap-core.de>
parents: 1141
diff changeset
14 search no more, because we have got your back with [UCX Test](test.h.md).

mercurial