Initial
This commit is contained in:
156
imagelst/RELATION.TPP
Normal file
156
imagelst/RELATION.TPP
Normal file
@@ -0,0 +1,156 @@
|
||||
#ifndef _IMAGELST_RELATION_HPP_
|
||||
#error relation.hpp must precede relation.tpp
|
||||
#endif
|
||||
|
||||
template <class T>
|
||||
Relation<T>::Relation(void)
|
||||
: mlpRContainer(0)
|
||||
{
|
||||
}
|
||||
|
||||
template <class T>
|
||||
Relation<T>::Relation(const Relation<T> &someRelation)
|
||||
{
|
||||
}
|
||||
|
||||
template <class T>
|
||||
Relation<T>::~Relation()
|
||||
{
|
||||
if(mlpRContainer){delete mlpRContainer;mlpRContainer=0;}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void Relation<T>::insert(const T &someItem,const T &insertAfter)
|
||||
{
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void Relation<T>::remove(const T &someItem)
|
||||
{
|
||||
}
|
||||
|
||||
template <class T>
|
||||
WORD Relation<T>::find(T &someItem)
|
||||
{
|
||||
if(!mlpRContainer)return FALSE;
|
||||
RContainer<T> *lpParentNode(mlpRContainer);
|
||||
|
||||
while(lpParentNode)
|
||||
{
|
||||
if(searchChildDescend(lpParentNode,someItem))return TRUE;
|
||||
lpParentNode=lpParentNode->sibling();
|
||||
}
|
||||
return FALSE;
|
||||
|
||||
}
|
||||
|
||||
template <class T>
|
||||
Relation<T> &Relation<T>::operator=(const Relation<T> &someRelation)
|
||||
{
|
||||
}
|
||||
|
||||
template <class T>
|
||||
WORD Relation<T>::operator==(const Relation<T> &someRelation)const
|
||||
{
|
||||
}
|
||||
|
||||
template <class T>
|
||||
RContainer<T> *Relation<T>::searchChildDescend(RContainer<T> *lpRContainer,T &someItem)
|
||||
{
|
||||
RContainer<T> *lpParentNode(lpRContainer);
|
||||
RContainer<T> *lpSiblingNode(0);
|
||||
|
||||
while(lpRContainer)
|
||||
{
|
||||
if(someItem==*(lpRContainer->item())){someItem=*lpRContainer->item();return lpRContainer;}
|
||||
lpRContainer=lpRContainer->child();
|
||||
if(lpRContainer->sibling())
|
||||
{
|
||||
lpSiblingNode=searchSiblingDescend(lpRContainer->sibling(),someItem);
|
||||
if(lpSiblingNode)return lpSiblingNode;
|
||||
}
|
||||
}
|
||||
return lpSiblingNode;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
RContainer<T> *Relation<T>::searchSiblingDescend(RContainer<T> *lpRContainer,T &someItem)
|
||||
{
|
||||
RContainer<T> *lpParentNode(lpRContainer);
|
||||
RContainer<T> *lpChildNode(0);
|
||||
|
||||
while(lpRContainer)
|
||||
{
|
||||
if(someItem==*(lpRContainer->item())){someItem=*(lpRContainer->item());return lpRContainer;}
|
||||
lpRContainer=lpRContainer->sibling();
|
||||
if(lpRContainer->child())
|
||||
{
|
||||
lpChildNode=searchChildDescend(lpRContainer->child(),someItem);
|
||||
if(lpChildNode)return lpChildNode;
|
||||
}
|
||||
}
|
||||
return lpChildNode;
|
||||
}
|
||||
|
||||
// Container methods
|
||||
|
||||
template <class T>
|
||||
RContainer<T>::RContainer(void)
|
||||
: mlpSibling(0), mlpParent(0), mlpChild(0), mlpItem(0)
|
||||
{
|
||||
}
|
||||
|
||||
template <class T>
|
||||
RContainer<T>::~RContainer()
|
||||
{
|
||||
if(mlpItem){delete mlpItem;mlpItem=0;}
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
RContainer<T> *RContainer<T>::sibling(void)
|
||||
{
|
||||
return mlpSibling;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void RContainer<T>::sibling(RContainer<T> *lpSibling)
|
||||
{
|
||||
mlpSibling=lpSibling;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
RContainer<T> *RContainer<T>::parent(void)
|
||||
{
|
||||
return mlpParent;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void RContainer<T>::parent(RContainer<T> *lpParent)
|
||||
{
|
||||
mlpParent=lpParent;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
RContainer<T> *RContainer<T>::child(void)
|
||||
{
|
||||
return mlpChild;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void RContainer<T>::child(RContainer<T> *lpChild)
|
||||
{
|
||||
mlpChild=lpChild;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
T *RContainer<T>::item(void)
|
||||
{
|
||||
return mlpItem;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void RContainer<T>::item(T *lpItem)
|
||||
{
|
||||
mlpItem=lpItem;
|
||||
}
|
||||
Reference in New Issue
Block a user