/*-
* Copyright 2016 Vsevolod Stakhov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef SRC_LIBUTIL_HEAP_H_
#define SRC_LIBUTIL_HEAP_H_
#include "config.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* Binary minimal heap interface based on glib
*/
struct rspamd_min_heap_elt {
gpointer data;
unsigned int pri;
unsigned int idx;
};
struct rspamd_min_heap;
/**
* Creates min heap with the specified reserved size and compare function
* @param reserved_size reserved size in elements
* @return opaque minimal heap
*/
struct rspamd_min_heap *rspamd_min_heap_create(gsize reserved_size);
/**
* Pushes an element to the heap. `pri` should be initialized to use this function,
* `idx` is used internally by heap interface
* @param heap heap structure
* @param elt element to push
*/
void rspamd_min_heap_push(struct rspamd_min_heap *heap,
struct rspamd_min_heap_elt *elt);
/**
* Pops the minimum element from the heap and reorder the queue
* @param heap heap structure
* @return minimum element
*/
struct rspamd_min_heap_elt *rspamd_min_heap_pop(struct rspamd_min_heap *heap);
/**
* Updates priority for the element. It must be in queue (so `idx` should be sane)
* @param heap heap structure
* @param elt element to update
* @param npri new priority
*/
void rspamd_min_heap_update_elt(struct rspamd_min_heap *heap,
struct rspamd_min_heap_elt *elt, unsigned int npri);
/**
* Removes element from the heap
* @param heap
* @param elt
*/
void rspamd_min_heap_remove_elt(struct rspamd_min_heap *heap,
struct rspamd_min_heap_elt *elt);
/**
* Destroys heap (elements are not destroyed themselves)
* @param heap
*/
void rspamd_min_heap_destroy(struct rspamd_min_heap *heap);
/**
* Returns element from the heap with the specified index
* @param heap
* @param idx
* @return
*/
struct rspamd_min_heap_elt *rspamd_min_heap_index(struct rspamd_min_heap *heap,
unsigned int idx);
#ifdef __cplusplus
}
#endif
#endif /* SRC_LIBUTIL_HEAP_H_ */
lue='search'/>
blob: 3649d6dc25268693224aee006e1c189c009bad14 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
# AWS User-specific
.idea/**/aws.xml
# Generated files
.idea/**/contentModel.xml
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr
# CMake
cmake-build-*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# SonarLint plugin
.idea/sonarlint/
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
|