summaryrefslogtreecommitdiffstats
path: root/contrib/restricted/aws/aws-c-common/source/priority_queue.c
diff options
context:
space:
mode:
authorthegeorg <[email protected]>2025-05-12 15:51:24 +0300
committerthegeorg <[email protected]>2025-05-12 16:06:27 +0300
commitd629bb70c8773d2c0c43f5088ddbb5a86d8c37ea (patch)
tree4f678e0d65ad08c800db21c657d3b0f71fafed06 /contrib/restricted/aws/aws-c-common/source/priority_queue.c
parent92c4b696d7a1c03d54e13aff7a7c20a078d90dd7 (diff)
Update contrib/restricted/aws libraries to nixpkgs 24.05
commit_hash:f8083acb039e6005e820cdee77b84e0a6b6c6d6d
Diffstat (limited to 'contrib/restricted/aws/aws-c-common/source/priority_queue.c')
-rw-r--r--contrib/restricted/aws/aws-c-common/source/priority_queue.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/contrib/restricted/aws/aws-c-common/source/priority_queue.c b/contrib/restricted/aws/aws-c-common/source/priority_queue.c
index 86a91feb3ae..fcea718bf2c 100644
--- a/contrib/restricted/aws/aws-c-common/source/priority_queue.c
+++ b/contrib/restricted/aws/aws-c-common/source/priority_queue.c
@@ -400,3 +400,27 @@ size_t aws_priority_queue_size(const struct aws_priority_queue *queue) {
size_t aws_priority_queue_capacity(const struct aws_priority_queue *queue) {
return aws_array_list_capacity(&queue->container);
}
+
+void aws_priority_queue_clear(struct aws_priority_queue *queue) {
+ AWS_PRECONDITION(aws_priority_queue_is_valid(queue));
+ size_t backpointer_count = aws_array_list_length(&queue->backpointers);
+ for (size_t i = 0; i < backpointer_count; ++i) {
+ struct aws_priority_queue_node *node = NULL;
+ aws_array_list_get_at(&queue->backpointers, &node, i);
+ if (node != NULL) {
+ node->current_index = SIZE_MAX;
+ }
+ }
+
+ aws_array_list_clear(&queue->backpointers);
+ aws_array_list_clear(&queue->container);
+ AWS_PRECONDITION(aws_priority_queue_is_valid(queue));
+}
+
+void aws_priority_queue_node_init(struct aws_priority_queue_node *node) {
+ node->current_index = SIZE_MAX;
+}
+
+bool aws_priority_queue_node_is_in_queue(const struct aws_priority_queue_node *node) {
+ return node->current_index != SIZE_MAX;
+}