示例#1
0
 ///////////////////////////////////////////////////////////////////////
 //  Function: error
 //
 //    Author: $author$
 //      Date: 7/18/2011
 ///////////////////////////////////////////////////////////////////////
 virtual void error
 (const nsXerces::SAXParseException& exception)
 {
     cXercesException cexception
     (e_XERCES_EXCEPTION_TYPE_ERROR, exception);
     throw(cexception);
 }
示例#2
0
   // recursively inserts (modeling on binary search) a key
   // pre: treeptr is assigned. newItem is assigned.
   // post: inserts the key in the tree with treeptr's root.
   //    If an empty position is found in the tree, key is inserted
   //    into that position. Else an exception is thrown.
   // usage: insertHelper (mroot, newItem);
void cbstree::insertHelper (Cnode*& treeptr, const Citem& newItem)
      throw (cexception)
{
   if (treeptr == NULL)
   {
      treeptr = new Cnode(newItem, NULL, NULL);
      if (treeptr == NULL)
      {
         throw cexception("Error! Insufficient memory to insert new key!");
      } else {
         itemCount++;
      }
   } else if (newItem == treeptr -> mitem)
   {
      throw cexception ("Error! A similar key already exists in the dictionary!");
   } else if (newItem < treeptr -> mitem)
   {
      insertHelper(treeptr -> mleftptr, newItem);
   } else {
      insertHelper(treeptr -> mrightptr, newItem);
   }
}
示例#3
0
   // recursively searches (modeling on binary search) for a key
   //@pre: treeptr is assigned. tkey and rest are assigned.
   // post: searches for the key in the tree with treeptr's root.
   //    If the key is found, rest is the key together with the other
   //    parts of the item. Else an exception is thrown.
   // usage: retrieveHelper (mroot, key, rest);
void cbstree::retrieveHelper (Cnode* treeptr, const Ckey& tkey,
                      Citem& rest) const throw (cexception)
{
   if (treeptr == NULL)
   {
      throw cexception ("No matches found for the key you entered." );
   } else if (tkey == treeptr-> mitem) {
      rest = treeptr -> mitem; 
   } else if (tkey < treeptr -> mitem) {
      retrieveHelper (treeptr -> mleftptr, tkey, rest); 
   } else {
      retrieveHelper (treeptr -> mrightptr, tkey, rest);
   }
}
示例#4
0
// recursively removes (modeling on binary search) a key
// pre: treeptr is assigned. tkey is assigned.
// post: removes the key in the tree with treeptr's root.
//       if the key to be removed is found, removeHelper deletes
//       the key. Else an exception is thrown
// usage: removeHelper (mroot, tkey);
void cbstree::removeHelper(Cnode*& treeptr, const Ckey& tkey)
{
   
   if (treeptr == NULL)
   {
      throw cexception ("Error! Cannot delete key! No matches found for the key you entered.");
   } else if (tkey == treeptr -> mitem)
   {
      removeNode(treeptr);
   } else if (tkey < treeptr -> mitem)
   {
      removeHelper(treeptr -> mleftptr, tkey);
   } else {
      removeHelper(treeptr -> mrightptr, tkey);
   }
}