• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

kstars

  • sources
  • kde-4.12
  • kdeedu
  • kstars
  • kstars
  • htmesh
HtmRange.cpp
Go to the documentation of this file.
1 #include <HtmRange.h>
2 
3 HtmRange::HtmRange()
4 {
5  my_los = new SkipList;
6  my_his = new SkipList;
7 }
8 
9 HtmRange::~HtmRange()
10 {
11  my_los->freeRange(-1, KEY_MAX);
12  my_his->freeRange(-1, KEY_MAX);
13  delete my_los;
14  delete my_his;
15 }
16 
17 InclusionType HtmRange::tinside(const Key mid) const
18 {
19  // clearly out, inside, share a bounday, off by one to some boundary
20  InclusionType t1, t2;
21 
22  Key GH = my_his->findMAX(mid);
23  Key GL = my_los->findMAX(mid);
24 
25  if (GH < GL)
26  t1 = InclInside;
27  else
28  t1 = InclOutside;
29 
30  Key SH = my_his->findMIN(mid);
31  Key SL = my_los->findMIN(mid);
32  if (SH < SL)
33  t2 = InclInside;
34  else
35  t2 = InclOutside;
36 
37  if( t1 == t2 )
38  return t1;
39  if( t1 == InclInside )
40  return InclHi;
41  else
42  return InclLo;
43 }
44 
45 void HtmRange::mergeRange(const Key lo, const Key hi)
46 {
47  int lo_flag = tinside(lo);
48  int hi_flag = tinside(hi);
49 
50  // delete all nodes (key) in his and los where lo < key < hi
51  my_his->freeRange(lo, hi);
52  my_los->freeRange(lo, hi);
53 
54  // add if not inside a pre-existing interval
55  if (lo_flag == InclHi) {
56  } else if (lo_flag == InclLo || (lo_flag == InclOutside) ) {
57  my_los->insert(lo, 33);
58  }
59 
60  if (hi_flag == InclLo){
61  } else if (hi_flag == InclOutside || hi_flag == InclHi) {
62  my_his->insert(hi, 33);
63  }
64 }
65 
66 void HtmRange::reset()
67 {
68  my_los->reset();
69  my_his->reset();
70 }
71 
72 int HtmRange::getNext(Key *lo, Key *hi)
73 {
74  *lo = my_los->getkey();
75  if (*lo <= (Key) 0){
76  *hi = *lo = (Key) 0;
77  return 0;
78  }
79  *hi = my_his->getkey();
80  my_his->step();
81  my_los->step();
82  return 1;
83 }
HtmRange::HtmRange
HtmRange()
Definition: HtmRange.cpp:3
KEY_MAX
#define KEY_MAX
Definition: SkipListElement.h:26
SkipList::step
int step()
Definition: SkipList.h:30
InclusionType
InclusionType
Definition: HtmRange.h:6
InclOutside
Definition: HtmRange.h:7
HtmRange.h
SkipList::reset
void reset()
Definition: SkipList.h:29
InclHi
Definition: HtmRange.h:10
HtmRange::reset
void reset()
Definition: HtmRange.cpp:66
SkipList::freeRange
void freeRange(const Key loKey, const Key hiKey)
Definition: SkipList.cpp:182
HtmRange::mergeRange
void mergeRange(const Key lo, const Key hi)
Definition: HtmRange.cpp:45
SkipList::findMAX
Key findMAX(const Key searchKey) const
search element with key NGT searchKey
Definition: SkipList.cpp:121
SkipList::getkey
Key getkey()
Definition: SkipList.h:34
InclInside
Definition: HtmRange.h:8
Key
int64 Key
Definition: SkipListElement.h:30
SkipList::insert
void insert(const Key searchKey, const Value value)
insert new element
Definition: SkipList.cpp:65
HtmRange::tinside
InclusionType tinside(const Key mid) const
Definition: HtmRange.cpp:17
InclLo
Definition: HtmRange.h:9
HtmRange::~HtmRange
~HtmRange()
Definition: HtmRange.cpp:9
HtmRange::getNext
int getNext(Key *lo, Key *hi)
Definition: HtmRange.cpp:72
SkipList::findMIN
Key findMIN(const Key searchKey) const
search element with key NLT searchKey
Definition: SkipList.cpp:153
SkipList
Definition: SkipList.h:17
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:36:19 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kstars

Skip menu "kstars"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal