/usr/include/vtk-5.8/vtkQtChartIndexRangeList.h is in libvtk5-dev 5.8.0-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 | /*=========================================================================
Program: Visualization Toolkit
Module: vtkQtChartIndexRangeList.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
/*-------------------------------------------------------------------------
Copyright 2008 Sandia Corporation.
Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
the U.S. Government retains certain rights in this software.
-------------------------------------------------------------------------*/
/// \file vtkQtChartIndexRangeList.h
/// \date March 26, 2009
#ifndef _vtkQtChartIndexRangeList_h
#define _vtkQtChartIndexRangeList_h
#include "vtkQtChartExport.h"
/// \class vtkQtChartIndexRange
/// \brief
/// The vtkQtChartIndexRange class is used to build a tree of index
/// ranges.
class VTKQTCHART_EXPORT vtkQtChartIndexRange
{
public:
vtkQtChartIndexRange();
/// \brief
/// Creates an index range instance.
/// \param first The first index in the range.
/// \param second The last index in the range.
/// \param black True if the node should be black.
vtkQtChartIndexRange(int first, int second, bool black=true);
vtkQtChartIndexRange(const vtkQtChartIndexRange &other);
~vtkQtChartIndexRange();
vtkQtChartIndexRange &operator=(const vtkQtChartIndexRange &other);
/// \name Index Range Methods
//@{
/// \brief
/// Gets the first index in the range.
/// \return
/// The first index in the range.
int getFirst() const {return this->First;}
/// \brief
/// Sets the first index in the range.
///
/// This method also updates the first index range for all the
/// affected parent nodes.
///
/// \param first The first index in the range.
void setFirst(int first);
/// \brief
/// Gets the last index in the range.
/// \return
/// The last index in the range.
int getSecond() const {return this->Second;}
/// \brief
/// Sets the last index in the range.
///
/// This method also updates the last index range for all the
/// affected parent nodes.
///
/// \param second The last index in the range.
void setSecond(int second);
/// \brief
/// Gets whether or not the given value is in the range.
/// \param value The value to find.
/// \return
/// True if the given value is in the range.
bool contains(int value) const;
//@}
/// \name Tree Methods
//@{
/// \brief
/// Gets whether the node is black or red.
/// \return
/// True if the node is black. False if the node is red.
bool isBlack() const {return this->Black;}
/// \brief
/// Sets whether the node is black or red.
/// \param black True if the node is black. False if the node is red.
void setBlack(bool black) {this->Black = black;}
/// \brief
/// Gets the parent node.
/// \return
/// A pointer to the parent node.
vtkQtChartIndexRange *getParent() const {return this->Parent;}
/// \brief
/// Sets the parent node.
/// \param parent The new parent node.
void setParent(vtkQtChartIndexRange *parent) {this->Parent = parent;}
/// \brief
/// Gets the left child node.
/// \return
/// A pointer to the left child node.
vtkQtChartIndexRange *getLeft() const {return this->Left;}
/// \brief
/// Sets the left child node.
/// \param left The new left child node.
void setLeft(vtkQtChartIndexRange *left) {this->Left = left;}
/// \brief
/// Gets the right child node.
/// \return
/// A pointer to the right child node.
vtkQtChartIndexRange *getRight() const {return this->Right;}
/// \brief
/// Sets the right child node.
/// \param right The new right child node.
void setRight(vtkQtChartIndexRange *right) {this->Right = right;}
//@}
private:
vtkQtChartIndexRange *Parent; ///< Stores the parent node.
vtkQtChartIndexRange *Left; ///< Stores the left child.
vtkQtChartIndexRange *Right; ///< Stores the right child.
bool Black; ///< Used to balance the tree.
int First; ///< Stores the range's first index.
int Second; ///< Stores the range's last index.
};
/// \class vtkQtChartIndexRangeList
/// \brief
/// The vtkQtChartIndexRangeList class stores a searchable list of
/// index ranges.
///
/// A modified red-black binary tree is used to store the ranges. The
/// red/black flag on each node is used to keep the tree balanced. Each
/// parent node holds the combined range of the two children. The leaf
/// nodes contain the list of actual ranges. The navigation and search
/// methods provide an interface to the leaf nodes.
class VTKQTCHART_EXPORT vtkQtChartIndexRangeList
{
public:
vtkQtChartIndexRangeList();
/// \brief
/// Creates an index range list instance with one range.
/// \param first The first index in the range.
/// \param second The last index in the range.
vtkQtChartIndexRangeList(int first, int second);
vtkQtChartIndexRangeList(const vtkQtChartIndexRangeList &other);
~vtkQtChartIndexRangeList();
vtkQtChartIndexRangeList &operator=(const vtkQtChartIndexRangeList &other);
/// \name Navigation Methods
//@{
/// \brief
/// Gets whether or not the list is empty.
/// \return
/// True if the list is empty.
bool isEmpty() const {return this->Root == 0;}
/// \brief
/// Gets the first index range in the list.
/// \return
/// A pointer to the first index range or null if the list is empty.
vtkQtChartIndexRange *getFirst() const;
/// \brief
/// Gets the last index range in the list.
/// \return
/// A pointer to the last index range or null if the list is empty.
vtkQtChartIndexRange *getLast() const;
/// \brief
/// Gets the next index range in the list.
/// \param range The index range to search from.
/// \return
/// A pointer to the next index range in the list or null if there
/// are no more nodes in the list.
vtkQtChartIndexRange *getNext(vtkQtChartIndexRange *range) const;
/// \brief
/// Gets the previous index range in the list.
/// \param range The index range to search from.
/// \return
/// A pointer to the previous index range in the list or null if
/// there are no more nodes in the list.
vtkQtChartIndexRange *getPrevious(vtkQtChartIndexRange *range) const;
//@}
/// \name Search Methods
//@{
/// \brief
/// Finds the closest index range to the given value.
/// \param value The value to search for.
/// \return
/// A pointer to the nearest index range or null if the list is
/// empty.
vtkQtChartIndexRange *findClosest(int value) const;
/// \brief
/// Gets whether or not the given value is contained in the list.
/// \return
/// True if the given value is contained in the list.
bool contains(int value) const;
//@}
/// \name Modification Methods
//@{
/// \brief
/// Clears the list of index ranges.
/// \return
/// True if the list was modified.
bool clear();
/// \brief
/// Sets the list to one index range.
/// \param first The first index in the range.
/// \param second The last index in the range.
/// \return
/// True if the list was modified.
bool setRange(int first, int second);
/// \brief
/// Copies the given list of index ranges.
/// \param ranges The list of index ranges to copy.
/// \return
/// True if the list was modified.
bool setRanges(const vtkQtChartIndexRangeList &ranges);
/// \brief
/// Adds the given index range to the list.
/// \param first The first index in the range.
/// \param second The last index in the range.
/// \return
/// True if the list was modified.
bool addRange(int first, int second);
/// \brief
/// Adds the list of index ranges to the list.
/// \param ranges The list of index ranges to add.
/// \return
/// True if the list was modified.
bool addRanges(const vtkQtChartIndexRangeList &ranges);
/// \brief
/// Subtracts the given index range from the list.
/// \param first The first index in the range.
/// \param second The last index in the range.
/// \return
/// True if the list was modified.
bool subtractRange(int first, int second);
/// \brief
/// Subtracts the list of index ranges to the list.
/// \param ranges The list of index ranges to subtract.
/// \return
/// True if the list was modified.
bool subtractRanges(const vtkQtChartIndexRangeList &ranges);
/// \brief
/// Sets the unique index ranges from the current list and the
/// given range.
/// \param first The first index in the range.
/// \param second The last index in the range.
/// \return
/// True if the list was modified.
bool xorRange(int first, int second);
/// \brief
/// Sets the unique index ranges from the current list and the
/// given list.
/// \param ranges The list of index ranges.
/// \return
/// True if the list was modified.
bool xorRanges(const vtkQtChartIndexRangeList &ranges);
/// \brief
/// Limits the list of index ranges to the given bounds.
/// \param minimum The minimum boundary of indexes.
/// \param maximum The maximum boundary of indexes.
void limitRange(int minimum, int maximum);
/// \brief
/// Offsets the indexes in the list.
///
/// The indexes are only modified if they are greater than or equal
/// to the given start index.
///
/// \param start The index to start changes.
/// \param offset The amount added to each index. Use a negative
/// value to subtract from each index.
/// \return
/// True if the list was modified.
bool offsetRanges(int start, int offset);
//@}
private:
/// \brief
/// Finds the bounding leaf node for the given value.
/// \param value The value to search for.
/// \param left True if the leaf should bound the value on the left.
/// False if the leaf should bound the value on the right.
/// \return
/// A pointer to the bounding leaf node.
vtkQtChartIndexRange *findNode(int value, bool left) const;
/// \brief
/// Rotates the given node left in the tree.
///
/// The tree root and the ranges are updated as well.
///
/// \param node The root of the rotation.
void rotateLeft(vtkQtChartIndexRange *node);
/// \brief
/// Rotates the given node right in the tree.
///
/// The tree root and the ranges are updated as well.
///
/// \param node The root of the rotation.
void rotateRight(vtkQtChartIndexRange *node);
/// \brief
/// Inserts a new leaf node into the tree.
///
/// A new parent node is inserted in place of the current node. The
/// current node and the new node are inserted as children of the
/// parent node. The nodes are ordered according to the \c left
/// parameter. The tree is rebalance after the insertion.
///
/// \param current The current tree node to insert near.
/// \param node The new leaf node.
/// \param left True if the new node should be inserted left of the
/// current node. False to be inserted to the right.
void insertNode(vtkQtChartIndexRange *current, vtkQtChartIndexRange *node,
bool left);
/// \brief
/// Removes the given leaf node from the tree.
///
/// The parent node is also deleted since it is no longer needed.
/// The node's sibling takes the place of the parent in the tree.
/// The tree is rebalanced after removing the nodes.
///
/// \param node The leaf node to remove.
/// \note
/// The node should be deleted after calling this method.
void removeNode(vtkQtChartIndexRange *node);
/// \brief
/// Removes all the leaf nodes between the given nodes.
/// \param left The left-most leaf node in the range.
/// \param right The right-most leaf node in the range.
int removeBetween(vtkQtChartIndexRange *left, vtkQtChartIndexRange *right);
/// \brief
/// Gets the next node in the tree.
/// \param node The starting node.
/// \return
/// A pointer to the next node in the tree.
vtkQtChartIndexRange *getNextNode(vtkQtChartIndexRange *node) const;
/// \brief
/// Gets the previous node in the tree.
/// \param node The starting node.
/// \return
/// A pointer to the previous node in the tree.
vtkQtChartIndexRange *getPreviousNode(vtkQtChartIndexRange *node) const;
/// \brief
/// Gets the left-most descendant in the given sub-tree.
/// \param root The root of the sub-tree to search.
/// \return
/// A pointer to the left-most descendant in the given sub-tree.
vtkQtChartIndexRange *getFirstNode(vtkQtChartIndexRange *root) const;
/// \brief
/// Gets the right-most descendant in the given sub-tree.
/// \param root The root of the sub-tree to search.
/// \return
/// A pointer to the right-most descendant in the given sub-tree.
vtkQtChartIndexRange *getLastNode(vtkQtChartIndexRange *root) const;
private:
vtkQtChartIndexRange *Root; ///< Stores the tree root.
};
#endif
|