From 75df00b3e3ca9b6f965730208384ce5d1165d8c1 Mon Sep 17 00:00:00 2001 From: "Sean Kessler (Europa)" Date: Fri, 16 Aug 2024 13:56:19 -0400 Subject: [PATCH] Updating --- bsptree/BSPTREE.BAK | 330 ----------------------------------------- bsptree/BTREE.BAK | 163 -------------------- bsptree/BTREE.TPP | 3 +- bsptree/Dictionary.hpp | 67 +++++++++ bsptree/Dictionary.tpp | 80 ++++++++++ 5 files changed, 149 insertions(+), 494 deletions(-) delete mode 100644 bsptree/BSPTREE.BAK delete mode 100644 bsptree/BTREE.BAK create mode 100644 bsptree/Dictionary.hpp create mode 100644 bsptree/Dictionary.tpp diff --git a/bsptree/BSPTREE.BAK b/bsptree/BSPTREE.BAK deleted file mode 100644 index 69c6d0f..0000000 --- a/bsptree/BSPTREE.BAK +++ /dev/null @@ -1,330 +0,0 @@ -# Microsoft Developer Studio Generated NMAKE File, Format Version 4.20 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Static Library" 0x0104 - -!IF "$(CFG)" == "" -CFG=bsptree - Win32 Debug -!MESSAGE No configuration specified. Defaulting to bsptree - Win32 Debug. -!ENDIF - -!IF "$(CFG)" != "bsptree - Win32 Release" && "$(CFG)" !=\ - "bsptree - Win32 Debug" -!MESSAGE Invalid configuration "$(CFG)" specified. -!MESSAGE You can specify a configuration when running NMAKE on this makefile -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "Bsptree.mak" CFG="bsptree - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "bsptree - Win32 Release" (based on "Win32 (x86) Static Library") -!MESSAGE "bsptree - Win32 Debug" (based on "Win32 (x86) Static Library") -!MESSAGE -!ERROR An invalid configuration is specified. -!ENDIF - -!IF "$(OS)" == "Windows_NT" -NULL= -!ELSE -NULL=nul -!ENDIF -################################################################################ -# Begin Project -# PROP Target_Last_Scanned "bsptree - Win32 Debug" -CPP=cl.exe - -!IF "$(CFG)" == "bsptree - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Target_Dir "" -OUTDIR=.\Release -INTDIR=.\Release - -ALL : "$(OUTDIR)\Bsptree.lib" - -CLEAN : - -@erase "$(INTDIR)\Bsptmpl.obj" - -@erase "$(INTDIR)\Rgbtree.obj" - -@erase "$(INTDIR)\Stdtmpl.obj" - -@erase "$(OUTDIR)\Bsptree.lib" - -"$(OUTDIR)" : - if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" - -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c -# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c -CPP_PROJ=/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS"\ - /Fp"$(INTDIR)/Bsptree.pch" /YX /Fo"$(INTDIR)/" /c -CPP_OBJS=.\Release/ -CPP_SBRS=.\. -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -BSC32_FLAGS=/nologo /o"$(OUTDIR)/Bsptree.bsc" -BSC32_SBRS= \ - -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo -LIB32_FLAGS=/nologo /out:"$(OUTDIR)/Bsptree.lib" -LIB32_OBJS= \ - "$(INTDIR)\Bsptmpl.obj" \ - "$(INTDIR)\Rgbtree.obj" \ - "$(INTDIR)\Stdtmpl.obj" - -"$(OUTDIR)\Bsptree.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS) - $(LIB32) @<< - $(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS) -<< - -!ELSEIF "$(CFG)" == "bsptree - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "msvcobj" -# PROP Intermediate_Dir "msvcobj" -# PROP Target_Dir "" -OUTDIR=.\msvcobj -INTDIR=.\msvcobj - -ALL : "..\exe\msbsp.lib" - -CLEAN : - -@erase "$(INTDIR)\Bsptmpl.obj" - -@erase "$(INTDIR)\Rgbtree.obj" - -@erase "$(INTDIR)\Stdtmpl.obj" - -@erase "..\exe\msbsp.lib" - -"$(OUTDIR)" : - if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" - -# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c -# ADD CPP /nologo /MTd /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "__FLAT__" /D "STRICT" /Fp"c:\work\exe\msvc42.pch" /YX /c -CPP_PROJ=/nologo /MTd /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D\ - "__FLAT__" /D "STRICT" /Fp"c:\work\exe\msvc42.pch" /YX /Fo"$(INTDIR)/" /c -CPP_OBJS=.\msvcobj/ -CPP_SBRS=.\. -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -BSC32_FLAGS=/nologo /o"$(OUTDIR)/Bsptree.bsc" -BSC32_SBRS= \ - -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo /out:"..\exe\msbsp.lib" -LIB32_FLAGS=/nologo /out:"..\exe\msbsp.lib" -LIB32_OBJS= \ - "$(INTDIR)\Bsptmpl.obj" \ - "$(INTDIR)\Rgbtree.obj" \ - "$(INTDIR)\Stdtmpl.obj" - -"..\exe\msbsp.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS) - $(LIB32) @<< - $(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS) -<< - -!ENDIF - -.c{$(CPP_OBJS)}.obj: - $(CPP) $(CPP_PROJ) $< - -.cpp{$(CPP_OBJS)}.obj: - $(CPP) $(CPP_PROJ) $< - -.cxx{$(CPP_OBJS)}.obj: - $(CPP) $(CPP_PROJ) $< - -.c{$(CPP_SBRS)}.sbr: - $(CPP) $(CPP_PROJ) $< - -.cpp{$(CPP_SBRS)}.sbr: - $(CPP) $(CPP_PROJ) $< - -.cxx{$(CPP_SBRS)}.sbr: - $(CPP) $(CPP_PROJ) $< - -################################################################################ -# Begin Target - -# Name "bsptree - Win32 Release" -# Name "bsptree - Win32 Debug" - -!IF "$(CFG)" == "bsptree - Win32 Release" - -!ELSEIF "$(CFG)" == "bsptree - Win32 Debug" - -!ENDIF - -################################################################################ -# Begin Source File - -SOURCE=.\Stdtmpl.cpp - -!IF "$(CFG)" == "bsptree - Win32 Release" - -DEP_CPP_STDTM=\ - {$(INCLUDE)}"\.\Btree.hpp"\ - {$(INCLUDE)}"\.\Btree.tpp"\ - {$(INCLUDE)}"\.\Treenode.hpp"\ - {$(INCLUDE)}"\.\Treenode.tpp"\ - {$(INCLUDE)}"\Common\array.hpp"\ - {$(INCLUDE)}"\Common\Assert.hpp"\ - {$(INCLUDE)}"\Common\Block.hpp"\ - {$(INCLUDE)}"\Common\Block.tpp"\ - {$(INCLUDE)}"\Common\except.hpp"\ - {$(INCLUDE)}"\Common\Fixup.hpp"\ - {$(INCLUDE)}"\Common\Pointer.hpp"\ - {$(INCLUDE)}"\Common\Pvector.hpp"\ - {$(INCLUDE)}"\Common\Pvector.tpp"\ - {$(INCLUDE)}"\Common\Stdlib.hpp"\ - {$(INCLUDE)}"\Common\String.hpp"\ - {$(INCLUDE)}"\Common\Types.hpp"\ - {$(INCLUDE)}"\Common\Windows.hpp"\ - - -"$(INTDIR)\Stdtmpl.obj" : $(SOURCE) $(DEP_CPP_STDTM) "$(INTDIR)" - - -!ELSEIF "$(CFG)" == "bsptree - Win32 Debug" - -DEP_CPP_STDTM=\ - {$(INCLUDE)}"\.\Btree.hpp"\ - {$(INCLUDE)}"\.\Btree.tpp"\ - {$(INCLUDE)}"\.\Treenode.hpp"\ - {$(INCLUDE)}"\.\Treenode.tpp"\ - {$(INCLUDE)}"\Common\array.hpp"\ - {$(INCLUDE)}"\Common\Assert.hpp"\ - {$(INCLUDE)}"\Common\Block.hpp"\ - {$(INCLUDE)}"\Common\Block.tpp"\ - {$(INCLUDE)}"\Common\except.hpp"\ - {$(INCLUDE)}"\Common\Fixup.hpp"\ - {$(INCLUDE)}"\Common\Pointer.hpp"\ - {$(INCLUDE)}"\Common\Pvector.hpp"\ - {$(INCLUDE)}"\Common\Pvector.tpp"\ - {$(INCLUDE)}"\Common\String.hpp"\ - {$(INCLUDE)}"\Common\Types.hpp"\ - {$(INCLUDE)}"\Common\Windows.hpp"\ - - -"$(INTDIR)\Stdtmpl.obj" : $(SOURCE) $(DEP_CPP_STDTM) "$(INTDIR)" - - -!ENDIF - -# End Source File -################################################################################ -# Begin Source File - -SOURCE=.\Rgbtree.cpp - -!IF "$(CFG)" == "bsptree - Win32 Release" - -DEP_CPP_RGBTR=\ - {$(INCLUDE)}"\.\Btree.hpp"\ - {$(INCLUDE)}"\.\Btree.tpp"\ - {$(INCLUDE)}"\.\Colorkey.hpp"\ - {$(INCLUDE)}"\.\Rgbndx.hpp"\ - {$(INCLUDE)}"\.\Rgbstack.hpp"\ - {$(INCLUDE)}"\.\Rgbtree.hpp"\ - {$(INCLUDE)}"\.\Treendex.hpp"\ - {$(INCLUDE)}"\.\Treenode.hpp"\ - {$(INCLUDE)}"\.\Treenode.tpp"\ - {$(INCLUDE)}"\Common\array.hpp"\ - {$(INCLUDE)}"\Common\Assert.hpp"\ - {$(INCLUDE)}"\Common\Block.hpp"\ - {$(INCLUDE)}"\Common\Block.tpp"\ - {$(INCLUDE)}"\Common\except.hpp"\ - {$(INCLUDE)}"\Common\Fixup.hpp"\ - {$(INCLUDE)}"\Common\Palentry.hpp"\ - {$(INCLUDE)}"\Common\Pointer.hpp"\ - {$(INCLUDE)}"\Common\Pvector.hpp"\ - {$(INCLUDE)}"\Common\Pvector.tpp"\ - {$(INCLUDE)}"\Common\Rgbcolor.hpp"\ - {$(INCLUDE)}"\Common\Types.hpp"\ - {$(INCLUDE)}"\Common\Windows.hpp"\ - - -"$(INTDIR)\Rgbtree.obj" : $(SOURCE) $(DEP_CPP_RGBTR) "$(INTDIR)" - - -!ELSEIF "$(CFG)" == "bsptree - Win32 Debug" - -DEP_CPP_RGBTR=\ - {$(INCLUDE)}"\.\Btree.hpp"\ - {$(INCLUDE)}"\.\Btree.tpp"\ - {$(INCLUDE)}"\.\Colorkey.hpp"\ - {$(INCLUDE)}"\.\Rgbndx.hpp"\ - {$(INCLUDE)}"\.\Rgbstack.hpp"\ - {$(INCLUDE)}"\.\Rgbtree.hpp"\ - {$(INCLUDE)}"\.\Treendex.hpp"\ - {$(INCLUDE)}"\.\Treenode.hpp"\ - {$(INCLUDE)}"\.\Treenode.tpp"\ - {$(INCLUDE)}"\Common\array.hpp"\ - {$(INCLUDE)}"\Common\Assert.hpp"\ - {$(INCLUDE)}"\Common\Block.hpp"\ - {$(INCLUDE)}"\Common\Block.tpp"\ - {$(INCLUDE)}"\Common\except.hpp"\ - {$(INCLUDE)}"\Common\Fixup.hpp"\ - {$(INCLUDE)}"\Common\Palentry.hpp"\ - {$(INCLUDE)}"\Common\Pointer.hpp"\ - {$(INCLUDE)}"\Common\Pvector.hpp"\ - {$(INCLUDE)}"\Common\Pvector.tpp"\ - {$(INCLUDE)}"\Common\Rgbcolor.hpp"\ - {$(INCLUDE)}"\Common\Types.hpp"\ - {$(INCLUDE)}"\Common\Windows.hpp"\ - - -"$(INTDIR)\Rgbtree.obj" : $(SOURCE) $(DEP_CPP_RGBTR) "$(INTDIR)" - - -!ENDIF - -# End Source File -################################################################################ -# Begin Source File - -SOURCE=.\Bsptmpl.cpp -DEP_CPP_BSPTM=\ - {$(INCLUDE)}"\.\Btree.hpp"\ - {$(INCLUDE)}"\.\Btree.tpp"\ - {$(INCLUDE)}"\.\Colorkey.hpp"\ - {$(INCLUDE)}"\.\Rgbndx.hpp"\ - {$(INCLUDE)}"\.\Treendex.hpp"\ - {$(INCLUDE)}"\.\Treenode.hpp"\ - {$(INCLUDE)}"\.\Treenode.tpp"\ - {$(INCLUDE)}"\Common\array.hpp"\ - {$(INCLUDE)}"\Common\Assert.hpp"\ - {$(INCLUDE)}"\Common\Block.hpp"\ - {$(INCLUDE)}"\Common\Block.tpp"\ - {$(INCLUDE)}"\Common\except.hpp"\ - {$(INCLUDE)}"\Common\Fixup.hpp"\ - {$(INCLUDE)}"\Common\Pointer.hpp"\ - {$(INCLUDE)}"\Common\Pvector.hpp"\ - {$(INCLUDE)}"\Common\Pvector.tpp"\ - {$(INCLUDE)}"\Common\Rgbcolor.hpp"\ - {$(INCLUDE)}"\Common\Types.hpp"\ - {$(INCLUDE)}"\Common\Windows.hpp"\ - - -"$(INTDIR)\Bsptmpl.obj" : $(SOURCE) $(DEP_CPP_BSPTM) "$(INTDIR)" - - -# End Source File -# End Target -# End Project -################################################################################ diff --git a/bsptree/BTREE.BAK b/bsptree/BTREE.BAK deleted file mode 100644 index cdeacd6..0000000 --- a/bsptree/BTREE.BAK +++ /dev/null @@ -1,163 +0,0 @@ -#ifndef _BSPTREE_BTREE_HPP_ -#define _BSPTREE_BTREE_HPP_ -#ifndef _COMMON_ASSERT_HPP_ -#include -#endif -#ifndef _COMMON_WINDOWS_HPP_ -#include -#endif -#ifndef _COMMON_PUREVECTOR_HPP_ -#include -#endif -#ifndef _COMMON_BLOCK_HPP_ -#include -#endif -#ifndef _COMMON_SMARTPOINTER_HPP_ -#include -#endif -#ifndef _BSPTREE_TREENODE_HPP_ -#include -#endif - -template -class BTree -{ -public: - BTree(void); - virtual ~BTree(); - DWORD leaves(void)const; - WORD insert(const T &someItem,DWORD dupsOk=FALSE); - WORD insert(PureVector &vectorItems); - void remove(const T &someItem); - BOOL searchItem(T &someItem); - BOOL searchItem(T &someItem,SmartPointer &nodeItem); - BOOL updateItem(T &someItem); - void treeItems(PureVector &vectoredItems)const; - void treeItems(Block &blockItems)const; - void remove(void); -protected: - virtual TreeNode *insertNode(TreeNode *lpRootNode,TreeNode *lpCurrentNode,const T &itemData); - virtual TreeNode *insertNodeDuplicate(TreeNode *lpRootNode,TreeNode *lpCurrentNode,const T &itemData); - virtual T *searchNode(TreeNode *lpRootNode,const T &someItem); - virtual TreeNode *deleteBTree(TreeNode *lpRootNode); - TreeNode *rootNode(void)const; - TreeNode *rootNode(TreeNode *lpRootNode); -private: - BTree(const BTree &someBTree); - BTree &operator=(const BTree &someBTree); - void leaves(DWORD leaves); - void remove(const T &someItem,TreeNode *pCurrNode,TreeNode *pParentNode); - void retrieveNodes(TreeNode *lpRootNode,PureVector &vectoredNodes,WORD &vectorIndex)const; - void retrieveNodes(TreeNode *lpRootNode,Block &blockNodes)const; - - TreeNode *mlpRootNode; - DWORD mLeaves; -}; - -template -inline -BTree::BTree(void) -: mlpRootNode(0), mLeaves(0) -{ -} - -template -inline -BTree::BTree(const BTree &/*someBTree*/) -: mlpRootNode(0), mLeaves(0) -{ // private implementation -} - -template -inline -BTree::~BTree() -{ - remove(); -} - -template -inline -BTree &BTree::operator=(const BTree &/*someBTree*/) -{ // private implementation - return *this; -} - -template -inline -WORD BTree::insert(const T &someItem,DWORD dupsOk) -{ - DWORD itemCount(leaves()); - - if(dupsOk) - { - if(!mlpRootNode)leaves(leaves()+(0!=(mlpRootNode=insertNodeDuplicate(mlpRootNode,mlpRootNode,someItem)))); - else leaves(leaves()+(0!=insertNodeDuplicate(mlpRootNode,mlpRootNode,someItem))); - } - else - { - if(!mlpRootNode)leaves(leaves()+(0!=(mlpRootNode=insertNode(mlpRootNode,mlpRootNode,someItem)))); - else leaves(leaves()+(0!=insertNode(mlpRootNode,mlpRootNode,someItem))); - } - return (!(itemCount==leaves())); -} - -template -inline -BOOL BTree::searchItem(T &someItem) -{ - T *lpTempItem=(searchNode(mlpRootNode,someItem)); - if(lpTempItem){someItem=*lpTempItem;return TRUE;} - else return FALSE; -} - -template -inline -BOOL BTree::searchItem(T &someItem,SmartPointer &nodeItem) -{ - T *lpTempItem=(searchNode(mlpRootNode,someItem)); - if(lpTempItem){nodeItem=lpTempItem;return TRUE;} - return FALSE; -} - -template -inline -void BTree::remove(void) -{ - mlpRootNode=deleteBTree(mlpRootNode); - leaves(0); -} - -template -inline -TreeNode *BTree::rootNode(void)const -{ - return mlpRootNode; -} - -template -inline -TreeNode *BTree::rootNode(TreeNode *lpRootNode) -{ - remove(); - return mlpRootNode=lpRootNode; -} - -template -inline -DWORD BTree::leaves(void)const -{ - return mLeaves; -} - -template -inline -void BTree::leaves(DWORD leaves) -{ - mLeaves=leaves; -} -#if defined(_MSC_VER) -#include -#endif -#endif - - diff --git a/bsptree/BTREE.TPP b/bsptree/BTREE.TPP index f72d8fb..f3e6afa 100644 --- a/bsptree/BTREE.TPP +++ b/bsptree/BTREE.TPP @@ -107,7 +107,8 @@ bool BTree::searchNodeDuplicate(TreeNode *lpRootNode,const T &someItem,Blo } while(lpRootNode&&someItem==lpRootNode->item()) { - items.insert(&SmartPointer(&lpRootNode->item())); +// items.insert(&SmartPointer(&lpRootNode->item())); + items.insert(new SmartPointer(&lpRootNode->item())); lpRootNode=lpRootNode->leftNode(); } return items.size()?true:false; diff --git a/bsptree/Dictionary.hpp b/bsptree/Dictionary.hpp new file mode 100644 index 0000000..d6227ec --- /dev/null +++ b/bsptree/Dictionary.hpp @@ -0,0 +1,67 @@ +#ifndef _BSPTREE_DICTIONARY_HPP_ +#define _BSPTREE_DICTIONARY_HPP_ +#include +#include + +template +class Dictionary +{ +public: + Dictionary(void); + Dictionary(const Dictionary& someDictionary); + virtual ~Dictionary(); + bool containsKey(const TKey& key); + bool insert(const TKey& key, const TValue& value); + TValue operator[](const TKey& key); + Block getValues(void)const; + Block getKeys(void)const; +private: + + template + class ItemEntry + { + public: + ItemEntry(void) + { + } + ItemEntry(const TKey& key, const TValue& value) + { + mKey = key; + mValue = value; + } + ItemEntry(const TKey& key) + { + mKey = key; + } + ~ItemEntry() + { + } + int operator==(const ItemEntry& item)const + { + return mKey == item.getKey(); + } + int operator<(const ItemEntry& item)const + { + return mKey < item.getKey(); + } + int operator>(const ItemEntry& item)const + { + return mKey > item.getKey(); + } + const TKey& getKey(void)const + { + return (TKey&)mKey; + } + TValue& getValue(void) + { + return mValue; + } + private: + TKey mKey; + TValue mValue; + }; + + BTree> data; +}; +#include +#endif diff --git a/bsptree/Dictionary.tpp b/bsptree/Dictionary.tpp new file mode 100644 index 0000000..4a30a18 --- /dev/null +++ b/bsptree/Dictionary.tpp @@ -0,0 +1,80 @@ +#ifndef _BSPTREE_DICTIONARY_HPP_ +#error DICTIONARY.HPP must precede DICTIONARY.TPP +#endif + +template +inline +Dictionary::Dictionary(void) +{ +} + +template +inline +Dictionary::Dictionary(const Dictionary& someDictionary) +{ + throw; +} + +template +inline +Dictionary::~Dictionary() +{ +} + +template +inline +bool Dictionary::containsKey(const TKey& key) +{ + ItemEntry item(key); + return data.find(item); +} + +template +inline +bool Dictionary::insert(const TKey& key, const TValue& value) +{ + ItemEntry item(key, value); + if (data.find(item))throw; + data.insert(item); + return true; +} + +template +inline +Block Dictionary::getValues(void)const +{ + Block> items = Block>(); + Block values = Block(); + + data.treeItems(items); + for (int index = 0;index < items.size();index++) + { + values.insert(&items[index].getValue()); + } + return values; +} + +template +inline +Block Dictionary::getKeys(void)const +{ + Block> items = Block>(); + Block keys = Block(); + + data.treeItems(items); + for (int index = 0;index < items.size();index++) + { + keys.insert(&items[index].getKey()); + } + return keys; +} + +template +inline +TValue Dictionary::operator[](const TKey& key) +{ + ItemEntry item(key); + if (!data.find(item))throw; + return item.getValue(); +} +#pragma once