# Classes used in this Library

- HnProperties
- HnPoint
- HnDataItem
- HnPointVector
- HnDataItemVector
- HnSphere
- HnRange
- HnRect
- HnSRTreeProfileSt

## HnProperties

> >     (C++)
> >         Class:
> >                 HnProperties

> >         Constructor:
> >                 HnProperties new_HnProperties(void);

> >         Methods:
> >                 HnString setProperty(const HnString &key, const HnString &value);
> >                 void load(const char *buffer);

> >     (C  )
> >         Structure:
> >                 HnPropertiesSt

> >         Allocation:
> >                 HnProperties *HnPropertiesSt_allocate(void);

> >         Deletion:
> >                 void HnPropertiesSt_free(HnPropertiesSt *properties);

> >         Methods:
> >                 void HnPropertiesSt_setProperty(HnPropertiesSt *properties,
> >                                                 const char *key,
> >                                                 const char *value);
> >                 void HnPropertiesSt_load(HnPropertiesSt *properties,
> >                                          const char *buffer);

> An object of the class ``HnProperties`' is a set of label-value pairs. Both labels and values are given in the form of a character string. For example, the following code allocates an object of the class ``HnProperties`' and then sets the property whose label and value are `HnSRTreeBlockSize' and `16384' respectively.

> >     (C++)
> >             HnProperties properties;

> >             properties = new_HnProperties();
> >             properties.setProperty("HnSRTreeBlockSize", "16384");

> >     (C  )
> >             HnPropertiesSt *properties;

> >             properties = HnPropertiesSt_allocate();
> >             HnPropertiesSt_setProperty(properties, "HnSRTreeBlockSize", "16384");

> In the C++ language interface, the arguments of the method ``setProperties`' has the type ``HnString`'. ``HnString`' is the class defined for a character string. Because this class has the type converter from a character string to itself, you can set character strings directly to the arguments of ``setProperties`'.

> Alternatively, properties can be loaded from a character string. The character string should consist of one or more lines and each line should be a label-value pair connected by the equal sign. For example, the following code loads two properties, ``A=B`' and ``P=Q`' from the character string `"A=B\nP=Q\n"`.

> >     (C++)
> >             properties.load("A=B\nP=Q\n");

> >     (C  )
> >             HnPropertiesSt_load(properties, "A=B\nP=Q\n");

## HnPoint

> >     (C++)
> >         Class:
> >                 HnPoint

> >         Constructor:
> >                 HnPoint new_HnPoint(int dimension);

> >         Methods:
> >                 int getDimension(void) const;
> >                 void setCoordAt(double coord, int index);
> >                 double &getCoordAt(int index) const;
> >                 double *getCoords(void) const;

> >                 HnBool equals(const HnPoint &point) const;
> >                 double getDistance(const HnPoint &point) const;
> >                 HnString toString(void) const;

> >     (C  )
> >         Structure:
> >                 HnPointSt

> >         Allocation:
> >                 HnPoint *HnPointSt_allocate(int dimension);

> >         Deletion:
> >                 void HnPointSt_free(HnPointSt *point);

> >         Member variables:
> >                 int dimension;
> >                 double *coords;

> >         Methods:
> >                 HnBool HnPointSt_equals(const HnPointSt *point1,
> >                                         const HnPointSt *point2);
> >                 HnPointSt_getDistance(const HnPointSt *point1,
> >                                       const HnPointSt *point2);
> >                 const char *HnPointSt_toString(const HnPointSt *point);

> The class ``HnPoint`' is used for allocating an object representing a point. A point whose coordinates are (0.2, 0.4, 0.6) can be allocated in the following way:

> >     (C++)
> >             HnPoint point;

> >             point = new_HnPoint(3);
> >             point.setCoordAt(0.2, 0);
> >             point.setCoordAt(0.4, 1);
> >             point.setCoordAt(0.6, 2);

> >     (C  )
> >             HnPointSt *point;

> >             point = HnPointSt_allocate(3);
> >             point->coords[0] = 0.2;
> >             point->coords[1] = 0.4;
> >             point->coords[2] = 0.6;

> The dimensionality and the coordinates of an object can be accessed in the following way:

> >     (C++)
> >             for ( i=0; i<point.getDimension(); i++ ) {
> >                 printf("%g\n", point.getCoordAt(i));
> >             }

> >     (C  )
> >             for ( i=0; i<point->dimension; i++ ) {
> >                 printf("%g\n", point->coords[i]);
> >             }

## HnDataItem

> >     (C++)
> >         Class:
> >                 HnDataItem

> >         Constructor:
> >                 HnDataItem new_HnDataItem(const void *bytes, int length);

> >         Methods:
> >                 int length(void) const;
> >                 char *toCharArray(void) const;

> >     (C  )
> >         Structure:
> >                 HnDataItemSt

> >         Allocation:
> >                 HnDataItemSt *HnDataItemSt_allocate(const char *bytes, int length);

> >         Deletion:
> >                 void HnDataItemSt_free(HnDataItemSt *dataItem);

> >         Member variables:
> >                 int length;
> >                 unsigned char *buffer;

> >         Methods:
> >                 HnDataItemSt_equals(const HnDataItemSt *dataItem1,
> >                                     const HnDataItemSt *dataItem2);

> The class ``HnDataItem`' is used for allocating an object which contains a piece of data in the form of a byte string. A data item whose content is the character string `"Hello world!"` can be allocated in the following way:

> >     (C++)
> >             char *s = "Hello world!";
> >             HnDataItem dataItem;

> >             dataItem = new_HnDataItem(s, strlen(s) + 1);

> >     (C  )
> >             char *s = "Hello world!";
> >             HnDataItemSt *dataItem;

> >             dataItem = HnDataItemSt_allocate(s, strlen(s) + 1);

> The content of an object can be accessed in the following way:

> >     (C++)
> >             printf("%s\n", dataItem.toCharArray());

> >     (C  )
> >             printf("%s\n", dataItem->buffer);

> In the following example, an integer value `1234` is stored in an object of the class ``HnDataItem`':

> >     (C++)
> >             int n = 1234;
> >             HnDataItem dataItem;

> >             dataItem = new_HnDataItem(&n, sizeof(n));

> >             printf("%d\n", *((int *)dataItem.toCharArray()));

> >     (C  )
> >             int n = 1234;
> >             HnDataItemSt *dataItem;

> >             dataItem = HnDataItemSt_allocate(&n, sizeof(n));

> >             printf("%d\n", *((int *)dataItem->buffer));

## HnPointVector

> >     (C++)
> >         Class:
> >                 HnPointVector

> >         Constructor:
> >                 HnPointVector new_HnPointVector(void);

> >         Methods:
> >                 /* access to elements */
> >                 int size(void) const;
> >                 HnPoint &elementAt(int index);
> >                 HnPoint &operator[](int index); // abbreviation of elementAt()

> >                 /* editing */
> >                 void addElement(const HnPoint &element);
> >                 void insertElementAt(const HnPoint &element, int index);
> >                 HnPoint removeElementAt(int index);
> >                 void setElementAt(const HnPoint &element, int index);

> >     (C  )
> >         Structure:
> >                 HnPointVectorSt

> >         Allocation:
> >                 HnPointVectorSt *HnPointVectorSt_allocate();

> >         Deletion:
> >                 void HnPointVectorSt_free(HnPointVectorSt *vector);

> >         Member variables:
> >                 int size;
> >                 HnPointSt **elements;

> >         Methods:
> >                 /* editing */
> >                 void HnPointVectorSt_addElement(HnPointVectorSt *vector,
> >                                                 HnPointSt *element);
> >                 void HnPointVectorSt_insertElementAt(HnPointVectorSt *vector,
> >                                                      HnPointSt *element, int index);
> >                 void HnPointVectorSt_removeElementAt(HnPointVectorSt *vector,
> >                                                      int index);
> >                 void HnPointVectorSt_setElementAt(HnPointVectorSt *vector,
> >                                                   HnPoint *element, int index);

> >                 /* utility */
> >                 void HnPointVectorSt_freeElements(const HnPointVectorSt *vector);

> An object of the class ``HnPointVector`' is a variable-length array of `HnPoint` objects. You can access the elements of an array in the following way:

> >     (C++)
> >             for ( i=0; i<vector.size(); i++ ) {
> >                 HnPoint element = vector.elementAt(i);

> >                 . . .
> >             }

> >     (C  )
> >             for ( i=0; i<vector->size; i++ ) {
> >                 HnPointSt *element = vector->elements[i];

> >                 . . .
> >             }

## HnDataItemVector

> >     (C++)
> >         Class:
> >                 HnDataItemVector

> >         Constructor:
> >                 HnDataItemVector new_HnDataItemVector(void);

> >         Methods:
> >                 /* access to elements */
> >                 int size(void) const;
> >                 HnDataItem &elementAt(int index);
> >                 HnDataItem &operator[](int index); // abbreviation of elementAt()

> >                 /* editing */
> >                 void addElement(const HnDataItem &element);
> >                 void insertElementAt(const HnDataItem &element, int index);
> >                 HnDataItem removeElementAt(int index);
> >                 void setElementAt(const HnDataItem &element, int index);

> >     (C  )
> >         Structure:
> >                 HnDataItemVectorSt

> >         Allocation:
> >                 HnDataItemVectorSt *HnDataItemVectorSt_allocate();

> >         Deletion:
> >                 void HnDataItemVectorSt_free(HnDataItemVectorSt *vector);

> >         Member variables:
> >                 int size;
> >                 HnDataItemSt **elements;

> >         Methods:
> >                 /* editing */
> >                 void HnDataItemVectorSt_addElement(HnDataItemVectorSt *vector,
> >                                                    HnDataItemSt *element);
> >                 void HnDataItemVectorSt_insertElementAt(HnDataItemVectorSt *vector,
> >                                                         HnDataItemSt *element, int index);
> >                 void HnDataItemVectorSt_removeElementAt(HnDataItemVectorSt *vector,
> >                                                         int index);
> >                 void HnDataItemVectorSt_setElementAt(HnDataItemVectorSt *vector,
> >                                                      HnDataItem *element, int index);

> >                 /* utility */
> >                 void HnDataItemVectorSt_freeElements(const HnDataItemVectorSt *vector);

> An object of the class ``HnDataItemVector`' is a variable-length array of `HnDataItem` objects. You can access the elements of the array as follows:

> >     (C++)
> >             for ( i=0; i<vector.size(); i++ ) {
> >                 HnDataItem element = vector.elementAt(i);

> >                 . . .
> >             }

> >     (C  )
> >             for ( i=0; i<vector->size; i++ ) {
> >                 HnDataItemSt *element = vector->elements[i];

> >                 . . .
> >             }

## HnSphere

> >     (C++)
> >         Class:
> >                 HnSphere

> >         Constructor:
> >                 HnSphere new_HnSphere(const HnPoint &center, double radius);

> >         Methods:
> >                 HnPoint &getCenter(void) const;
> >                 double getRadius(void) const;
> >                 int getDimension(void) const;

> >     (C  )
> >         Structure:
> >                 HnSphereSt

> >         Allocation:
> >                 HnSphereSt *HnSphereSt_allocate(int dimension);

> >         Deletion:
> >                 void HnSphereSt_free(HnSphereSt *sphere);

> >         Member variables:
> >                 HnPoint *center;
> >                 double *radius;

> > See also HnPoint.

> The class ``HnSphere`' is used for allocating an object representing a sphere. For example, the following code allocates a 3-dimensional sphere whose center is (0.2, 0.4, 0.6) and whose radius is 0.8:

> >     (C++)
> >             HnPoint center;
> >             HnSphere sphere;

> >             center = new_HnPoint(3);
> >             center.setCoordAt(0.2, 0);
> >             center.setCoordAt(0.4, 1);
> >             center.setCoordAt(0.6, 2);

> >             sphere = new_HnSphere(center, 0.8);

> >     (C  )
> >             HnSphereSt *sphere;

> >             sphere = HnSphereSt_allocate(3);
> >             sphere->center->coords[0] = 0.2;
> >             sphere->center->coords[1] = 0.4;
> >             sphere->center->coords[2] = 0.6;
> >             sphere->radius = 0.8;

> The dimensionality, coordinates, and radius of a sphere can be obtained in the following way:

> >     (C++)
> >             for ( i=0; i<sphere.getDimension(); i++ ) {
> >                 printf("coords[%d]=%g\n",
> >                        i, sphere.getCenter().getCoordAt(i));
> >             }
> >             printf("radius=%g\n", sphere.getRadius());

> >     (C  )
> >             for ( i=0; i<sphere->center->dimension; i++ ) {
> >                 printf("coords[%d]=%g\n",
> >                        i, sphere->center->coords[i]);
> >             }
> >             printf("radius=%g\n", sphere->radius);

## HnRange

> >     (C++)
> >         Class:
> >                 HnRange

> >         Constructor:
> >                 Not applicable (this class is prepared only for `HnRect').

> >         Methods:
> >                 void set(double minValue, double maxValue);
> >                 double getMin(void) const;
> >                 double getMax(void) const;

> >     (C  )
> >         Structure:
> >                 HnRangeSt

> >         Allocation:
> >         Deletion:
> >                 Not applicable (this class is prepared only for `HnRectSt').

> >         Member variables:
> >                 double min;
> >                 double max;

> > See also HnRect.

> The class ``HnRange`' is used for allocating an object representing a range which is specified by two numerical values: the minimum and the maximum. This class is prepared for the class ``HnRect`' that represents a rectangle.

## HnRect

> >     (C++)
> >         Class:
> >                 HnRect

> >         Constructor:
> >                 HnRect new_HnRect(int dimension);

> >         Methods:
> >                 int getDimension(void) const;
> >                 HnRange &getRangeAt(int index) const;
> >                 void setRangeAt(double min, double max, int index);

> >     (C  )
> >         Structure:
> >                 HnRectSt

> >         Allocation:
> >                 HnRectSt *HnRectSt_allocate(int dimension);

> >         Deletion:
> >                 void HnRectSt_free(HnRectSt *rect);

> >         Member variables:
> >                 int dimension;
> >                 HnRangeSt *ranges;

> > See also HnRange.

> The class ``HnRect`' is used for allocating an object representing a (axis-aligned) rectangle. For example, the following code allocates a 3-dimensional rectangle whose ranges are 0.2 to 0.3 in the first dimension, 0.4 to 0.5 in the second, and 0.6 to 0.7 in the third:

> >     (C++)
> >             HnRect rect;

> >             rect = new_HnRect(3);
> >             rect.setRangeAt(0.2, 0.3, 0);
> >             rect.setRangeAt(0.4, 0.5, 1);
> >             rect.setRangeAt(0.6, 0.7, 2);

> >     (C  )
> >             HnRectSt *rect;

> >             rect = HnRectSt_allocate(3);
> >             rect->ranges[0].min = 0.2;
> >             rect->ranges[0].max = 0.3;
> >             rect->ranges[1].min = 0.4;
> >             rect->ranges[1].max = 0.5;
> >             rect->ranges[2].min = 0.6;
> >             rect->ranges[2].max = 0.7;

> The dimensionality and the coordinates of a rectangle can be obtained in the following way:

> >     (C++)
> >             for ( i=0; i<rect.getDimension(); i++ ) {
> >                 printf("min=%g, max=%g\n",
> >                        rect.getRangeAt(i).getMin(), rect.getRangeAt(i).getMax());
> >             }

> >     (C  )
> >             for ( i=0; i<rect->dimension; i++ ) {
> >                 printf("min=%g, max=%g\n",
> >                        rect->ranges[i].min, rect->ranges[i].max);
> >             }

## HnSRTreeProfileSt

> >     (C++ and C)
> >         Structure:
> >                 HnSRTreeProfileSt

> >         Allocation:
> >                 HnSRTreeProfileSt *HnSRTreeProfileSt_allocate(void);

> >         Deletion:
> >                 void HnSRTreeProfileSt_free(HnSRTreeProfileSt *profile);

> >         Member variables:
> >                 /* block I/O */
> >                 int numSuperBlockReads;
> >                 int numSuperBlockWrites;
> >                 int numNodeBlockReads;
> >                 int numNodeBlockWrites;
> >                 int numLeafBlockReads;
> >                 int numLeafBlockWrites;

> >                 /* split */
> >                 int numNodeSplits;
> >                 int numLeafSplits;

> >                 /* search */
> >                 int numVisitedNodes;
> >                 int numVisitedLeaves;
> >                 int numComparedNodeEntries;
> >                 int numComparedLeafEntries;

> >                 /* nearest neighbor search */
> >                 int numEqualDistances;
> >                 int numFartherSpheres;
> >                 int numFartherRects;

> >         Methods:
> >                 void HnSRTreeProfileSt_print(const HnSRTreeProfileSt *profile);

> The structure ``HnSRTreeProfileSt`' is used to keep the profile information of an index file.

> The member variables, ``numEqualDistances`', ``numFartherSpheres`', and ``numFartherRects`', store the characteristics on the distance measurement in nearest neighbor search. The variable ``numEqualDistances`' stores the count of the case that the bounding sphere and the bounding rectangle of a region has the same distance to the query point. The variable ``numFartherSpheres`' stores the count of the case that the distance from the query point to the bounding sphere is longer than the one to the bounding rectangle, while ``numFartherRects`' stores the count of the opposite case.

[TOC] [Library] [Classes] [Commands] [Examples] [References]

Any feedback is appreciated (corrections, suggestions, etc.).