-
Notifications
You must be signed in to change notification settings - Fork 3
/
HeapEntry.h
39 lines (32 loc) · 1.45 KB
/
HeapEntry.h
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
#ifndef _HEAP_ENTRY_H
#define _HEAP_ENTRY_H
template <class IT, class NT> class HeapEntry {
public:
IT key;
IT runr;
IT loc; // location of the next nonzero that column of A
NT value;
// Operators are swapped for performance
// If you want/need to convert them back to their normal definitions, don't
// forget to add "greater< HeapEntry<T> >()" optional parameter to all the
// heap operations operating on HeapEntry<T> objects. For example:
// push_heap(heap, heap + kisect, greater< HeapEntry<T> >());
bool operator>(const HeapEntry &rhs) const { return (key < rhs.key); }
bool operator<(const HeapEntry &rhs) const { return (key > rhs.key); }
bool operator==(const HeapEntry &rhs) const { return (key == rhs.key); }
};
template <class IT> class HeapEntry<IT, void> {
public:
IT key;
IT runr;
IT loc; // location of the current nonzero that column of A (absolute)
// Operators are swapped for performance
// If you want/need to convert them back to their normal definitions, don't
// forget to add "greater< HeapEntry<T> >()" optional parameter to all the
// heap operations operating on HeapEntry<T> objects. For example:
// push_heap(heap, heap + kisect, greater< HeapEntry<T> >());
bool operator>(const HeapEntry &rhs) const { return (key < rhs.key); }
bool operator<(const HeapEntry &rhs) const { return (key > rhs.key); }
bool operator==(const HeapEntry &rhs) const { return (key == rhs.key); }
};
#endif