Click here to Skip to main content
15,891,744 members
Articles / Programming Languages / Objective C

Fast Binary Tree Operations

Rate me:
Please Sign up or sign in to vote.
4.75/5 (44 votes)
22 Jan 20057 min read 255.1K   6.1K   107  
Describes main binary tree operations
// BinaryTreeDemoDlg.h : header file
//

#pragma once
#include "afxwin.h"
#include "afxcmn.h"
#include "RBTree.h"

#define RBTNODE CRBTreeNode<string, HTREEITEM>
#define TNODE CBinaryTreeNode<string, HTREEITEM>

// CBinaryTreeDemoDlg dialog
class CBinaryTreeDemoDlg : public CDialog
{
// Construction
public:
	CBinaryTreeDemoDlg(CWnd* pParent = NULL);	// standard constructor

// Dialog Data
	enum { IDD = IDD_BINARYTREEDEMO_DIALOG };
	CSize m_size;
	CImageList m_imageList;

	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support

	int ParseFolder(LPCSTR lpcsFolder);
	void InsertItem(int nChild, TNODE* pNode, HTREEITEM hParent);
	void Expand(TNODE* pNode);
	void Select(TNODE* pNode);

// Implementation
protected:
	HICON m_hIcon;
	CRBTree<string, LPCSTR, HTREEITEM, HTREEITEM> m_rbTree;

	// Generated message map functions
	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	DECLARE_MESSAGE_MAP()
public:
	CStatic m_staticStatus;
	CTreeCtrl m_tree;
	CString m_strFolder;
	CString m_strExt;
	BOOL m_bRedBlack;
	afx_msg void OnBnClickedBrowse();
	afx_msg void OnBnClickedOk();
	afx_msg void OnBnClickedClear();
	afx_msg void OnBnClickedDelete();
	afx_msg void OnBnClickedSuccessor();
	afx_msg void OnBnClickedPredecessor();
	afx_msg void OnBnClickedMin();
	afx_msg void OnBnClickedMax();
	afx_msg void OnTvnItemexpandingTree1(NMHDR *pNMHDR, LRESULT *pResult);
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg void OnBnClickedCheck1();
	afx_msg void OnDestroy();
};

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


Written By
Software Developer (Senior)
Egypt Egypt

Comments and Discussions