summaryrefslogtreecommitdiffhomepage
path: root/docs/cpque_api.md
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2021-01-20 14:09:38 +0100
committerGitHub <[email protected]>2021-01-20 14:09:38 +0100
commite78984b583e85273fdeb5461f2740ca895250314 (patch)
tree366a926996252e6f5f1e94d3e38fd76fc8c0ed0b /docs/cpque_api.md
parent1c9613395b1e6b9a16a1c20cd992d4d600d62726 (diff)
downloadSTC-modified-e78984b583e85273fdeb5461f2740ca895250314.tar.gz
STC-modified-e78984b583e85273fdeb5461f2740ca895250314.zip
Update cpque_api.md
Diffstat (limited to 'docs/cpque_api.md')
-rw-r--r--docs/cpque_api.md11
1 files changed, 5 insertions, 6 deletions
diff --git a/docs/cpque_api.md b/docs/cpque_api.md
index 276f1ce3..59203a63 100644
--- a/docs/cpque_api.md
+++ b/docs/cpque_api.md
@@ -1,19 +1,18 @@
# STC Container [cpque](../stc/cpque.h): Priority Queue
A priority queue is a container adaptor that provides constant time lookup of the largest (by default) element, at the expense of logarithmic insertion and extraction.
+A user-provided argument `<`or `>` must be supplied to set the ordering, e.g. using `>` would cause the smallest element to appear as the top().
-See [std::priority_queue](https://en.cppreference.com/w/cpp/container/priority_queue) for a similar c++ class.
-
-Working with a priority_queue is similar to managing a heap in some random access container, with the benefit of not being able to accidentally invalidate the heap.
+See the c++ class [std::priority_queue](https://en.cppreference.com/w/cpp/container/priority_queue) for a functional reference.
## Declaration
```c
-#define using_cpque(X, ctype, heap_variant)
+#define using_cpque(X, ctype, direction)
```
The macro `using_cpque()` must be instantiated in the global scope.
**cpque** uses normally **cvec_X** or **cdeq_X** as underlying implementation, specified as `ctype`.
-The `heap_variant` must be given as `<` or `>`, specifying *max-heap* or *min-heap* for the priority queue to change the ordering, e.g. `>` would cause the smallest element to appear as the *cpque_X_top()*.
+The *direction* must be given as `<` or `>`, specifying *max-heap* or *min-heap* for the priority queue.
Note that the function `{ctype}_value_compare(x, y)` defined by the underlying vector type is used to
compare values (priorities). `X` is a type tag name and will affect the names of all cpque types and methods.
@@ -89,4 +88,4 @@ int main()
Output:
```
-873 -343 -231 -32 -4 3 5 6 18 23 31 54 68 87 99 105 107 125 128 147 150 155 167 178 181 188 213 216 272 284 287 302 306 311 313 326 329 331 344 348 363 367 374 385 396 399 401 407 412 477
-``` \ No newline at end of file
+```