-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathradixheap.h
More file actions
66 lines (56 loc) · 1.75 KB
/
Copy pathradixheap.h
File metadata and controls
66 lines (56 loc) · 1.75 KB
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
// Copyright 2017 Shane Saunders (???), and Kyle Vedder (kvedder@umass.edu)
// College of Information and Computer Sciences,
// University of Massachusetts Amherst
//
// This software is free: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License Version 3,
// as published by the Free Software Foundation.
//
// This software is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// Version 3 in the file COPYING that came with this distribution.
// If not, see <http://www.gnu.org/licenses/>.
// ========================================================================
#ifndef RADIXHEAP_H
#define RADIXHEAP_H
//#define RADIXHEAP_DEBUG
namespace datastructures {
namespace radix {
namespace heap {
class RadixHeapNode {
public:
int item;
int64_t key;
int bucket;
RadixHeapNode *next, *prev;
};
class RadixHeap {
public:
RadixHeap(int n, int MaxKey);
~RadixHeap();
int deleteMin();
void insert(int item, int64_t k);
void decreaseKey(int item, int64_t newValue);
int nItems() const { return itemCount; }
int64_t nComps() const { return compCount; }
void dump() const;
private:
void placeNode(int startBucket, RadixHeapNode *node);
void insertNode(int i, RadixHeapNode *node);
void removeNode(RadixHeapNode *node);
RadixHeapNode **nodes;
RadixHeapNode *bucketHeaders;
int *u;
int nBuckets;
int dMin;
int itemCount;
int compCount;
};
} // namespace heap
} // namespace radix
} // namespace datastructures
#endif // RADIXHEAP_H