Kstars

HtmRange.cpp
1#include <HtmRange.h>
2
3#include <stdio.h>
4#include <string.h>
5
6#define INSIDE 1
7#define OUTSIDE -1
8#define INTERSECT 0
9#define GAP_HISTO_SIZE 10000
10
11extern "C" {
12int cc_ID2name(char *name, uint64 id);
13}
14
15HtmRange::HtmRange()
16{
17 my_los = new SkipList;
18 my_his = new SkipList;
19}
20
21HtmRange::~HtmRange()
22{
23 my_los->freeRange(-1, KEY_MAX);
24 my_his->freeRange(-1, KEY_MAX);
25 delete my_los;
26 delete my_his;
27}
28
29InclusionType HtmRange::tinside(const Key mid) const
30{
31 // clearly out, inside, share a boundary, off by one to some boundary
32 InclusionType t1, t2;
33
34 Key GH = my_his->findMAX(mid);
35 Key GL = my_los->findMAX(mid);
36
37 if (GH < GL)
38 t1 = InclInside;
39 else
40 t1 = InclOutside;
41
42 Key SH = my_his->findMIN(mid);
43 Key SL = my_los->findMIN(mid);
44 if (SH < SL)
45 t2 = InclInside;
46 else
47 t2 = InclOutside;
48
49 if (t1 == t2)
50 return t1;
51 if (t1 == InclInside)
52 return InclHi;
53 else
54 return InclLo;
55}
56
57void HtmRange::mergeRange(const Key lo, const Key hi)
58{
59 int lo_flag = tinside(lo);
60 int hi_flag = tinside(hi);
61
62 // delete all nodes (key) in his and los where lo < key < hi
63 my_his->freeRange(lo, hi);
64 my_los->freeRange(lo, hi);
65
66 // add if not inside a pre-existing interval
67 if (lo_flag == InclHi)
68 {
69 }
70 else if (lo_flag == InclLo || (lo_flag == InclOutside))
71 {
72 my_los->insert(lo, 33);
73 }
74
75 if (hi_flag == InclLo)
76 {
77 }
78 else if (hi_flag == InclOutside || hi_flag == InclHi)
79 {
80 my_his->insert(hi, 33);
81 }
82}
83
84void HtmRange::reset()
85{
86 my_los->reset();
87 my_his->reset();
88}
89
90int HtmRange::getNext(Key *lo, Key *hi)
91{
92 *lo = my_los->getkey();
93 if (*lo <= (Key)0)
94 {
95 *hi = *lo = (Key)0;
96 return 0;
97 }
98 *hi = my_his->getkey();
99 my_his->step();
100 my_los->step();
101 return 1;
102}
Extends LineList by adding the skip hash to allow the same the data in a LineList to be drawn as a fi...
Definition SkipList.h:18
void insert(const Key searchKey, const Value value)
insert new element
Definition SkipList.cpp:63
Key findMAX(const Key searchKey) const
search element with key NGT searchKey
Definition SkipList.cpp:127
Key findMIN(const Key searchKey) const
search element with key NLT searchKey
Definition SkipList.cpp:163
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:04:46 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.