MetaTree Class Developer's Manual

From Catcliffe Development
Jump to navigation Jump to search


clsMetaTree Developer's Manual

Overview

clsMetaTree is a sophisticated VB6 class designed to manage a dynamic and complex data structure that integrates the functionalities of a binary tree, a linked list, and sorted indices. This manual serves as a guide for developers to understand, utilize, and extend clsMetaTree within their applications.

Features

  • Dynamic Data Structure: Combines binary tree and linked list paradigms for efficient data organization and retrieval.
  • Sorting and Indexing: Supports multiple sorting criteria with the ability to generate and maintain sorted indices.
  • Flexible Data Management: Allows for the addition, deletion, searching, and traversal of data in a structured manner.

Key Components

  • udtMetaTreeNode: A User-Defined Type (UDT) that encapsulates the node's data and its relational pointers, including next, previous, lesser, greater, and equivalence chain links.
  • mNodes: A private collection within clsMetaTree that stores all nodes, facilitating easy management and traversal of the data structure.

Methods

Class_Initialize

Initializes the clsMetaTree instance, preparing it for use.

Usage
Automatically called upon instantiation of clsMetaTree.

Add(Data As Variant, Optional SortCriteria As String)

Adds a new element to the MetaTree based on the provided data and optional sorting criteria.

Parameters
  • Data: The data to be stored within the new node.
  • SortCriteria: (Optional) The criteria used to determine the node's position within the binary tree structure.
Usage
Dim tree As New clsMetaTree
tree.Add "Sample Data"

Sort(SortCriteria As String)

Sorts the MetaTree based on the provided sorting criteria, affecting the traversal order of the nodes.

Parameters
  • SortCriteria: The criteria determining how the tree should be sorted.
Usage
tree.Sort "MySortCriteria"

GetSortedData(SortCriteria As String) As Collection

Retrieves data from the MetaTree in sorted order based on the specified criteria.

Parameters
  • SortCriteria: The criteria used for sorting the data.
Usage
Dim sortedData As Collection
Set sortedData = tree.GetSortedData("MySortCriteria")

Find(Data As Variant, Optional Criteria As String) As udtMetaTreeNode

Searches for a node based on the provided data and optional criteria.

Parameters
  • Data: The data to search for within the tree.
  • Criteria: (Optional) Additional criteria to refine the search.
Usage
Dim foundNode As udtMetaTreeNode
Set foundNode = tree.Find("Search Data")

Extending clsMetaTree

Developers can extend clsMetaTree by adding methods for additional functionalities such as rebalancing the tree, extracting subsets of data based on complex criteria, or integrating with external data sources.

Best Practices

  • Initialization: Ensure clsMetaTree is properly initialized before use.
  • Memory Management: Be mindful of memory usage, especially with large datasets. Consider implementing cleanup routines.
  • Sorting Criteria: Keep sorting criteria consistent and well-defined to ensure the integrity of the sorted indices.