dtinfo subtree DtMmdb
This commit is contained in:
committed by
Jon Trulson
parent
b92cf08899
commit
8c8363f4a5
@@ -56,7 +56,7 @@ CC_TPtrDlist<T>::CC_TPtrDlist(const CC_TPtrDlist<T>&adlist)
|
||||
template <class T>
|
||||
void CC_TPtrDlist<T>::clear()
|
||||
{
|
||||
if ( !destructed ) {
|
||||
if ( !this->get_destructed() ) {
|
||||
CC_TPtrSlistIterator<T> iter(*this);
|
||||
if (++iter) {
|
||||
while (1) {
|
||||
@@ -82,7 +82,7 @@ template <class T>
|
||||
void CC_TPtrDlist<T>::clearAndDestroy()
|
||||
{
|
||||
|
||||
destructed = TRUE;
|
||||
this->set_destructed(TRUE);
|
||||
CC_TPtrDlistIterator<T> iter(*this);
|
||||
if ( ++iter ) {
|
||||
while (1) {
|
||||
|
||||
@@ -41,23 +41,6 @@ CC_TPtrSlist<T>::CC_TPtrSlist(const CC_TPtrSlist<T>&slist)
|
||||
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------
|
||||
template<class T>
|
||||
T *CC_TPtrSlist<T>::at(size_t pos) const
|
||||
{
|
||||
|
||||
// Hack to get it passed to iter
|
||||
CC_TPtrSlistIterator<T> iter( *(CC_TPtrSlist<T> *)this );
|
||||
for ( int i = 0; i <=pos; i++ ) {
|
||||
if ( !(++iter) ) {
|
||||
throw(CASTCCBEXCEPT ccBoundaryException(0,0,i));
|
||||
}
|
||||
}
|
||||
|
||||
return( iter.key() );
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
template<class T>
|
||||
T *CC_TPtrSlist<T>::removeAt(size_t pos) {
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#define __CC_Slist_h
|
||||
|
||||
#include "CC_Listbase.h"
|
||||
#include "cc_exceptions.h"
|
||||
|
||||
template <class T> class CC_TPtrSlist;
|
||||
template <class T> class CC_TPtrSlistIterator;
|
||||
@@ -65,7 +66,7 @@ class CC_TPtrSlist : public CC_Listbase
|
||||
friend class CC_List_Iterator<T>;
|
||||
|
||||
protected:
|
||||
CC_Boolean destructed;
|
||||
CC_Boolean destructed;
|
||||
|
||||
// Inherit public members from CC_Listbase
|
||||
/*
|
||||
@@ -97,9 +98,20 @@ public:
|
||||
void insert(T* element)
|
||||
{ CC_Listbase::append (new CC_Link<T> (element)); }
|
||||
|
||||
T* at(size_t pos) const; /* throw boundaryException
|
||||
T* at(size_t pos) const /* throw boundaryException
|
||||
* if list size is smaller than pos
|
||||
*/
|
||||
{
|
||||
// Hack to get it passed to iter
|
||||
CC_TPtrSlistIterator<T> iter( *(CC_TPtrSlist<T> *)this );
|
||||
for ( int i = 0; i <=pos; i++ ) {
|
||||
if ( !(++iter) ) {
|
||||
throw(CASTCCBEXCEPT ccBoundaryException(0,0,i));
|
||||
}
|
||||
}
|
||||
|
||||
return( iter.key() );
|
||||
}
|
||||
|
||||
T* removeAt(size_t pos); /* throw boundaryException
|
||||
* if list size is smaller than pos
|
||||
@@ -146,7 +158,11 @@ public:
|
||||
|
||||
operator CC_Listbase *() { return(this); }
|
||||
|
||||
CC_Boolean get_destructed() const
|
||||
{ return (destructed); }
|
||||
|
||||
CC_Boolean set_destructed(CC_Boolean what)
|
||||
{ destructed = what; }
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -23,54 +23,3 @@
|
||||
// $XConsortium: CC_Stack.C /main/4 1996/10/08 19:22:53 cde-hal $
|
||||
#include "CC_Stack.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
template <class T> Stack<T>::Stack ()
|
||||
{
|
||||
Items = new CC_TValSlist<T>();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
template <class T> Stack<T>::~Stack ()
|
||||
{
|
||||
delete Items;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
template <class T>
|
||||
void
|
||||
Stack<T>::push (const T newItem)
|
||||
{
|
||||
Items->append ( newItem );
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
template <class T>
|
||||
T
|
||||
Stack<T>::pop () {
|
||||
CC_Link<T> *last_elem = (CC_Link<T> *)Items->removeLast();
|
||||
|
||||
if ( !last_elem ) {
|
||||
throw (Exception());
|
||||
}
|
||||
|
||||
T *ret = last_elem->f_element;
|
||||
delete last_elem;
|
||||
|
||||
T ret_value = *ret;
|
||||
delete ret;
|
||||
|
||||
return(ret_value);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
template <class T>
|
||||
T&
|
||||
Stack<T>::top () const
|
||||
{
|
||||
CC_Link<T> *last_elem = (CC_Link<T> *)Items->last();
|
||||
if ( !last_elem ) {
|
||||
throw(Exception());
|
||||
}
|
||||
|
||||
return ( *last_elem->f_element );
|
||||
}
|
||||
|
||||
@@ -31,19 +31,55 @@ template <class T> class Stack: public Destructable
|
||||
{
|
||||
|
||||
public:
|
||||
Stack (); /* This is a value stack, ie an assignment operator
|
||||
* for T is assumed */
|
||||
/* This is a value stack, ie an assignment operator for T is assumed */
|
||||
Stack ()
|
||||
{
|
||||
Items = new CC_TValSlist<T>();
|
||||
}
|
||||
|
||||
~Stack ();
|
||||
~Stack ()
|
||||
{
|
||||
delete Items;
|
||||
}
|
||||
|
||||
public:
|
||||
T pop ();
|
||||
void push (const T);
|
||||
T& top () const;
|
||||
T pop ()
|
||||
{
|
||||
CC_Link<T> *last_elem = (CC_Link<T> *)Items->removeLast();
|
||||
|
||||
if ( !last_elem ) {
|
||||
throw (Exception());
|
||||
}
|
||||
|
||||
T *ret = last_elem->f_element;
|
||||
delete last_elem;
|
||||
|
||||
T ret_value = *ret;
|
||||
delete ret;
|
||||
|
||||
return(ret_value);
|
||||
}
|
||||
|
||||
void push (const T newItem)
|
||||
{
|
||||
Items->append ( newItem );
|
||||
}
|
||||
|
||||
T& top () const
|
||||
{
|
||||
CC_Link<T> *last_elem = (CC_Link<T> *)Items->last();
|
||||
if ( !last_elem ) {
|
||||
throw(Exception());
|
||||
}
|
||||
|
||||
return ( *last_elem->f_element );
|
||||
}
|
||||
|
||||
int entries() const
|
||||
{
|
||||
return( Items->entries() ); //ie no. of elements in the stack
|
||||
}
|
||||
|
||||
int empty() const {
|
||||
return( Items->entries() == 0 );
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
// $XConsortium: cc_exceptions.C /main/4 1996/08/21 15:48:54 drk $
|
||||
|
||||
#include "dti_cc/cc_exceptions.h"
|
||||
using namespace std;
|
||||
|
||||
ostream& ccException::asciiOut(ostream& out)
|
||||
{
|
||||
@@ -43,7 +44,7 @@ ostream& ccBoundaryException::asciiOut(ostream& out)
|
||||
{
|
||||
cerr << low << "\t";
|
||||
cerr << high << "\t";
|
||||
cerr << index << "\n";
|
||||
cerr << mindex << "\n";
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,9 @@
|
||||
#ifndef _cc_exception_h
|
||||
#define _cc_exception_h 1
|
||||
|
||||
#include <fstream.h>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
#include "Exceptions.hh"
|
||||
|
||||
#define END_TRY end_try
|
||||
@@ -36,15 +38,9 @@
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
#if defined(linux)
|
||||
#define CASTCCEXCEPT (ccException*)
|
||||
#define CASTCCSEXCEPT (ccStringException*)
|
||||
#define CASTCCBEXCEPT (ccBoundaryException*)
|
||||
#else
|
||||
#define CASTCCEXCEPT
|
||||
#define CASTCCSEXCEPT
|
||||
#define CASTCCBEXCEPT
|
||||
#endif
|
||||
|
||||
class ccException : public Exception
|
||||
{
|
||||
@@ -69,7 +65,7 @@ protected:
|
||||
public:
|
||||
DECLARE_EXCEPTION(ccStringException, ccException);
|
||||
|
||||
ccStringException(char* m) : msg(m) {};
|
||||
ccStringException(char const* m) : msg((char*)m) {};
|
||||
~ccStringException() {};
|
||||
|
||||
virtual ostream& asciiOut(ostream&);
|
||||
@@ -81,13 +77,13 @@ class ccBoundaryException : public ccException
|
||||
protected:
|
||||
int low;
|
||||
int high;
|
||||
int index;
|
||||
int mindex;
|
||||
|
||||
public:
|
||||
DECLARE_EXCEPTION(ccBoundaryException, ccException);
|
||||
|
||||
ccBoundaryException(int l, int h, int i) :
|
||||
low(l), high(h), index(i) {};
|
||||
low(l), high(h), mindex(i) {};
|
||||
~ccBoundaryException() {};
|
||||
|
||||
virtual ostream& asciiOut(ostream&);
|
||||
|
||||
@@ -1,30 +1,8 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these librararies and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
// $TOG: cc_hdict.C /main/5 1998/04/17 11:45:00 mgreess $
|
||||
|
||||
#include "dti_cc/cc_exceptions.h"
|
||||
|
||||
#if !defined(__osf__) && !defined(linux)
|
||||
#if !defined(__osf__)
|
||||
template <class K, class V> CC_Boolean kv_pair<K, V>::f_needRemove = FALSE;
|
||||
#endif
|
||||
|
||||
|
||||
@@ -29,7 +29,8 @@
|
||||
#include "dti_cc/cc_pvect.h"
|
||||
#include "dti_cc/CC_Slist.h"
|
||||
|
||||
#include <iostream.h>
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
template <class K, class V>
|
||||
class kv_pair {
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#define _cc_dlist_array_h
|
||||
|
||||
#include "dti_cc/CC_Dlist.h"
|
||||
#include "dti_cc/cc_exceptions.h"
|
||||
|
||||
template <class T>
|
||||
class dlist_array : public CC_TPtrDlist<T>
|
||||
@@ -46,6 +47,21 @@ public:
|
||||
T* first() ;
|
||||
*/
|
||||
|
||||
T* at(size_t pos) const /* throw boundaryException
|
||||
* if list size is smaller than pos
|
||||
*/
|
||||
{
|
||||
// Hack to get it passed to iter
|
||||
CC_TPtrSlistIterator<T> iter( *(CC_TPtrSlist<T> *)this );
|
||||
for ( int i = 0; i <=pos; i++ ) {
|
||||
if ( !(++iter) ) {
|
||||
throw(CASTCCBEXCEPT ccBoundaryException(0,0,i));
|
||||
}
|
||||
}
|
||||
|
||||
return( iter.key() );
|
||||
}
|
||||
|
||||
T* operator()(size_t i) const { return at(i); };
|
||||
T* operator[](size_t i) const { return at(i); };
|
||||
};
|
||||
|
||||
@@ -50,7 +50,7 @@ pointer_vector<T>::~pointer_vector()
|
||||
}
|
||||
|
||||
template <class T>
|
||||
T* pointer_vector<T>::operator[](size_t i) const
|
||||
T* pointer_vector<T>::operator[](ptrdiff_t i) const
|
||||
{
|
||||
if ( i<0 || i>= f_size )
|
||||
throw(CASTCCBEXCEPT ccBoundaryException(0, f_size-1, i));
|
||||
@@ -59,7 +59,7 @@ T* pointer_vector<T>::operator[](size_t i) const
|
||||
}
|
||||
|
||||
template <class T>
|
||||
T*& pointer_vector<T>::operator[](size_t i)
|
||||
T*& pointer_vector<T>::operator[](ptrdiff_t i)
|
||||
{
|
||||
if ( i<0 || i>= f_size )
|
||||
throw(CASTCCBEXCEPT ccBoundaryException(0, f_size-1, i));
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#ifndef _cc_pvector_h
|
||||
#define _cc_pvector_h 1
|
||||
|
||||
#include <stddef.h>
|
||||
#include "dti_cc/types.h"
|
||||
|
||||
template <class T>
|
||||
@@ -45,8 +46,8 @@ public:
|
||||
pointer_vector(size_t, T* = 0);
|
||||
~pointer_vector();
|
||||
|
||||
T* operator[](size_t) const;
|
||||
T*& operator[](size_t);
|
||||
T* operator[](ptrdiff_t) const;
|
||||
T*& operator[](ptrdiff_t);
|
||||
|
||||
// size_t entries() const { return f_items; };
|
||||
size_t length() const { return f_size; };
|
||||
|
||||
Reference in New Issue
Block a user