Initial import of the CDE 2.1.30 sources from the Open Group.
This commit is contained in:
79
cde/programs/dtinfo/DtMmdb/dti_cc/CC_Dlist.C
Normal file
79
cde/programs/dtinfo/DtMmdb/dti_cc/CC_Dlist.C
Normal file
@@ -0,0 +1,79 @@
|
||||
// $XConsortium: CC_Dlist.cc /main/5 1996/08/06 09:27:22 rcs $
|
||||
#ifndef __CC_Dlist_cc
|
||||
#define __CC_Dlist_cc
|
||||
|
||||
#include "Exceptions.hh"
|
||||
#include "cc_exceptions.h"
|
||||
#include "CC_Dlist.h"
|
||||
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
template <class T>
|
||||
CC_Boolean CC_TPtrDlistIterator<T>::operator+=(size_t n)
|
||||
{
|
||||
for ( int i = 0; i < n ; i++ ) {
|
||||
if ( !(++(*this)) ) {
|
||||
return (FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
template <class T>
|
||||
CC_TPtrDlist<T>::CC_TPtrDlist(const CC_TPtrDlist<T>&adlist)
|
||||
{
|
||||
CC_TPtrDlistIterator<T> dlist_iter( *(CC_TPtrDlist<T> *)&adlist );
|
||||
while ( dlist_iter() ) {
|
||||
insert ( dlist_iter.key() );
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
template <class T>
|
||||
void CC_TPtrDlist<T>::clear()
|
||||
{
|
||||
if ( !destructed ) {
|
||||
CC_TPtrSlistIterator<T> iter(*this);
|
||||
if (++iter) {
|
||||
while (1) {
|
||||
CC_Link<T> *elem = (CC_Link<T> *)CC_Listbase::remove( (CC_List_Iterator_base &)iter );
|
||||
if ( elem ) {
|
||||
delete elem;
|
||||
}
|
||||
else { break; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
template <class T>
|
||||
CC_TPtrDlist<T>::~CC_TPtrDlist()
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
template <class T>
|
||||
void CC_TPtrDlist<T>::clearAndDestroy()
|
||||
{
|
||||
|
||||
destructed = TRUE;
|
||||
CC_TPtrDlistIterator<T> iter(*this);
|
||||
if ( ++iter ) {
|
||||
while (1) {
|
||||
CC_Link<T> *elem = (CC_Link<T> *)CC_Listbase::remove( (CC_List_Iterator_base &)iter );
|
||||
if ( elem ) {
|
||||
T *temp_elem = elem->f_element;
|
||||
delete temp_elem;
|
||||
elem->f_element = NULL; // prevent further destruction on this pointer
|
||||
delete elem;
|
||||
}
|
||||
else { break; }
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
82
cde/programs/dtinfo/DtMmdb/dti_cc/CC_Dlist.h
Normal file
82
cde/programs/dtinfo/DtMmdb/dti_cc/CC_Dlist.h
Normal file
@@ -0,0 +1,82 @@
|
||||
/* $XConsortium: CC_Dlist.h /main/5 1996/08/21 15:48:36 drk $ */
|
||||
#ifndef __CC_Dlist_h
|
||||
#define __CC_Dlist_h
|
||||
|
||||
#include "CC_Listbase.h"
|
||||
#include "CC_Slist.h"
|
||||
|
||||
template <class T> class CC_TPtrDlist;
|
||||
template <class T> class CC_TPtrDlistIterator;
|
||||
|
||||
template <class T>
|
||||
class CC_TPtrDlist : public CC_TPtrSlist<T>
|
||||
{
|
||||
friend class CC_TPtrDlistIterator<T>;
|
||||
|
||||
// Inherit all the public/protected members from CC_TPtrSlist<T>
|
||||
/*
|
||||
entries();
|
||||
prepend(T*element);
|
||||
append(T*element);
|
||||
insert(T*element);
|
||||
at(size_t);
|
||||
removeAt
|
||||
removeLast
|
||||
removeFirst
|
||||
first
|
||||
last
|
||||
T *find(const T*)
|
||||
T *find(Boolean...)
|
||||
contains
|
||||
remove
|
||||
operator CC_Listbase *
|
||||
*/
|
||||
|
||||
public:
|
||||
CC_TPtrDlist(const CC_TPtrDlist<T>&);
|
||||
|
||||
CC_TPtrDlist() {}
|
||||
~CC_TPtrDlist();
|
||||
void clear();
|
||||
virtual void clearAndDestroy();
|
||||
|
||||
operator CC_TPtrSlist<T> *() { return(this); }
|
||||
|
||||
};
|
||||
|
||||
|
||||
template <class T>
|
||||
class CC_TPtrDlistIterator : public CC_TPtrSlistIterator<T>
|
||||
{
|
||||
|
||||
/* all the inherited member from CC_TPtrSlistIterator<T> and
|
||||
* List_Iterator_base...
|
||||
*/
|
||||
// From CC_TPtrSlistIterator<T>
|
||||
// T *key() const
|
||||
// T *operator()()
|
||||
// Boolean operator++()
|
||||
|
||||
|
||||
// From CC_Listbase_Iterator
|
||||
// Boolean operator--();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
CC_TPtrDlistIterator (CC_TPtrDlist<T> &list)
|
||||
: CC_TPtrSlistIterator<T>( *((CC_TPtrSlist<T> *)&list) )
|
||||
{ }
|
||||
|
||||
|
||||
CC_Boolean operator+=(size_t n);
|
||||
|
||||
};
|
||||
|
||||
#ifdef EXPAND_TEMPLATES
|
||||
#include "CC_Dlist.C"
|
||||
#endif
|
||||
|
||||
#endif /* __CC_Slist_h */
|
||||
/* DO NOT ADD ANY LINES AFTER THIS #endif */
|
||||
|
||||
249
cde/programs/dtinfo/DtMmdb/dti_cc/CC_Listbase.C
Normal file
249
cde/programs/dtinfo/DtMmdb/dti_cc/CC_Listbase.C
Normal file
@@ -0,0 +1,249 @@
|
||||
/*
|
||||
* $TOG: CC_Listbase.C /main/4 1998/04/17 11:44:10 mgreess $
|
||||
* $TOG: CC_Listbase.C /main/4 1998/04/17 11:44:10 mgreess $
|
||||
* $TOG: CC_Listbase.C /main/4 1998/04/17 11:44:10 mgreess $
|
||||
* $TOG: CC_Listbase.C /main/4 1998/04/17 11:44:10 mgreess $
|
||||
*
|
||||
* Copyright (c) 1993 HAL Computer Systems International, Ltd.
|
||||
* All rights reserved. Unpublished -- rights reserved under
|
||||
* the Copyright Laws of the United States. USE OF A COPYRIGHT
|
||||
* NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
|
||||
* OR DISCLOSURE.
|
||||
*
|
||||
* THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
|
||||
* SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
|
||||
* DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
|
||||
* PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
|
||||
* INTERNATIONAL, LTD.
|
||||
*
|
||||
* RESTRICTED RIGHTS LEGEND
|
||||
* Use, duplication, or disclosure by the Government is subject
|
||||
* to the restrictions as set forth in subparagraph (c)(l)(ii)
|
||||
* of the Rights in Technical Data and Computer Software clause
|
||||
* at DFARS 252.227-7013.
|
||||
*
|
||||
* HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
|
||||
* 1315 Dell Avenue
|
||||
* Campbell, CA 95008
|
||||
*
|
||||
*/
|
||||
#include "Exceptions.hh"
|
||||
#include "cc_exceptions.h"
|
||||
#include "CC_Listbase.h"
|
||||
|
||||
// /////////////////////////////////////////////////////////////////
|
||||
// CC_Listbase::insert - append a new link to the end of the list
|
||||
// /////////////////////////////////////////////////////////////////
|
||||
|
||||
void
|
||||
CC_Listbase::insert (CC_Link_base *element)
|
||||
{
|
||||
if (!element) {
|
||||
throw(CASTCCEXCEPT ccException());
|
||||
}
|
||||
|
||||
if (!f_tail) {
|
||||
f_tail = f_head = element;
|
||||
}
|
||||
else {
|
||||
f_tail->f_next = element;
|
||||
element->f_prev = f_tail;
|
||||
f_tail = element;
|
||||
}
|
||||
|
||||
f_length++;
|
||||
}
|
||||
|
||||
|
||||
// /////////////////////////////////////////////////////////////////
|
||||
// CC_Listbase::insert - insert a new link into the list
|
||||
// /////////////////////////////////////////////////////////////////
|
||||
|
||||
void
|
||||
CC_Listbase::prepend (CC_Link_base *element)
|
||||
{
|
||||
|
||||
if ( !element ) {
|
||||
throw(CASTCCEXCEPT ccException());
|
||||
}
|
||||
|
||||
if ( !f_head ) {
|
||||
f_head = element;
|
||||
}
|
||||
else {
|
||||
element->f_next = f_head;
|
||||
f_head->f_prev = element;
|
||||
f_head = element;
|
||||
}
|
||||
|
||||
if (f_tail == NULL)
|
||||
f_tail = element;
|
||||
f_length++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// /////////////////////////////////////////////////////////////////
|
||||
// CC_Listbase::remove - remove element pointed to by iterator
|
||||
// /////////////////////////////////////////////////////////////////
|
||||
CC_Link_base *
|
||||
CC_Listbase::remove (CC_List_Iterator_base &iterator)
|
||||
{
|
||||
// Make sure the iterator points to this this.
|
||||
if (iterator.f_list != this)
|
||||
throw (CASTCCEXCEPT ccException());
|
||||
|
||||
// Make sure the iterator is pointing to an element.
|
||||
if (iterator.f_current == NULL)
|
||||
return(NULL);
|
||||
|
||||
// NOTE: If two iterators are active in the list at the same time
|
||||
// it is possible to blow away an element that another iterator
|
||||
// is pointing at (either previous or current). We could make this
|
||||
// safer by only marking elements as deleted for now, then actually
|
||||
// delete the items when there are no more iterators pointing at it.
|
||||
// 19:41 22-Jul-93 DJB
|
||||
|
||||
// Link around the link we're removing.
|
||||
if (iterator.f_previous != NULL) {
|
||||
iterator.f_previous->f_next = iterator.f_current->f_next;
|
||||
if ( f_tail != iterator.f_current ) {
|
||||
iterator.f_current->f_next->f_prev = iterator.f_previous;
|
||||
}
|
||||
}
|
||||
else { // must be at the head
|
||||
f_head = iterator.f_current->f_next;
|
||||
if ( f_head ) {
|
||||
f_head->f_prev = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (iterator.f_current == f_tail) {
|
||||
f_tail = iterator.f_previous;
|
||||
if ( f_tail ) {
|
||||
f_tail->f_next = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Increment the iterator.
|
||||
CC_Link_base *entry = iterator.f_current;
|
||||
iterator.f_current = iterator.f_current->f_next;
|
||||
|
||||
f_length--;
|
||||
|
||||
return (entry);
|
||||
}
|
||||
|
||||
CC_Link_base *
|
||||
CC_Listbase::removeFirst()
|
||||
{
|
||||
if ( f_head ) {
|
||||
|
||||
CC_Link_base *remove_item = f_head;
|
||||
f_head = f_head->f_next;
|
||||
remove_item->f_next = NULL;
|
||||
|
||||
if ( f_head ) {
|
||||
f_head->f_prev = NULL;
|
||||
}
|
||||
|
||||
if ( f_tail == remove_item ) { /* only one item on the list */
|
||||
f_tail = NULL;
|
||||
}
|
||||
|
||||
f_length--;
|
||||
return(remove_item);
|
||||
}
|
||||
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
CC_Link_base *
|
||||
CC_Listbase::removeLast()
|
||||
{
|
||||
if ( f_tail ) {
|
||||
CC_Link_base *remove_item = f_tail;
|
||||
f_tail = f_tail->f_prev;
|
||||
remove_item->f_prev = NULL;
|
||||
|
||||
if ( f_tail ) {
|
||||
f_tail->f_next = NULL;
|
||||
}
|
||||
if ( f_head == remove_item ) { // one item left on the list
|
||||
f_head = NULL;
|
||||
}
|
||||
f_length--;
|
||||
return(remove_item);
|
||||
}
|
||||
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
// /////////////////////////////////////////////////////////////////
|
||||
// CC_List_Iterator::CC_List_Iterator - class constructor
|
||||
// /////////////////////////////////////////////////////////////////
|
||||
|
||||
CC_List_Iterator_base::CC_List_Iterator_base (CC_Listbase *list)
|
||||
: f_list (list)
|
||||
{
|
||||
if ( !list ) {
|
||||
throw(CASTCCEXCEPT ccException());
|
||||
}
|
||||
|
||||
reset();
|
||||
}
|
||||
|
||||
// /////////////////////////////////////////////////////////////////
|
||||
// CC_List_Iterator::reset - reset the iterator to the list start
|
||||
// /////////////////////////////////////////////////////////////////
|
||||
|
||||
void
|
||||
CC_List_Iterator_base::reset()
|
||||
{
|
||||
f_current = f_previous = NULL;
|
||||
}
|
||||
|
||||
|
||||
// /////////////////////////////////////////////////////////////////
|
||||
// CC_List_Iterator:: operator ++ - increment the list iterator
|
||||
// /////////////////////////////////////////////////////////////////
|
||||
|
||||
CC_Boolean
|
||||
CC_List_Iterator_base::operator++()
|
||||
{
|
||||
if (!f_current) { // havn't touched the first element
|
||||
f_current = f_list->first();
|
||||
f_previous = NULL;
|
||||
if ( f_current ) return ( TRUE );
|
||||
else return(FALSE);
|
||||
}
|
||||
|
||||
f_previous = f_current;
|
||||
f_current = f_current->f_next;
|
||||
|
||||
if ( f_current ) {
|
||||
return(TRUE);
|
||||
}
|
||||
else {
|
||||
return(FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
CC_Boolean
|
||||
CC_List_Iterator_base::operator--()
|
||||
{
|
||||
if (!f_current) {
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
f_current = f_previous;
|
||||
if ( f_previous ) {
|
||||
f_previous = f_previous->f_prev;
|
||||
}
|
||||
|
||||
if ( f_current ) { return(TRUE); }
|
||||
else { return(FALSE); }
|
||||
}
|
||||
|
||||
129
cde/programs/dtinfo/DtMmdb/dti_cc/CC_Listbase.h
Normal file
129
cde/programs/dtinfo/DtMmdb/dti_cc/CC_Listbase.h
Normal file
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
* $XConsortium: CC_Listbase.h /main/4 1996/08/21 15:48:41 drk $
|
||||
*
|
||||
* Copyright (c) 1993 HAL Computer Systems International, Ltd.
|
||||
* All rights reserved. Unpublished -- rights reserved under
|
||||
* the Copyright Laws of the United States. USE OF A COPYRIGHT
|
||||
* NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
|
||||
* OR DISCLOSURE.
|
||||
*
|
||||
* THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
|
||||
* SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
|
||||
* DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
|
||||
* PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
|
||||
* INTERNATIONAL, LTD.
|
||||
*
|
||||
* RESTRICTED RIGHTS LEGEND
|
||||
* Use, duplication, or disclosure by the Government is subject
|
||||
* to the restrictions as set forth in subparagraph (c)(l)(ii)
|
||||
* of the Rights in Technical Data and Computer Software clause
|
||||
* at DFARS 252.227-7013.
|
||||
*
|
||||
* HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
|
||||
* 1315 Dell Avenue
|
||||
* Campbell, CA 95008
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _CC_Listbase_hh
|
||||
#define _CC_Listbase_hh
|
||||
|
||||
#include <stdio.h>
|
||||
#include "dti_cc/types.h"
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
// forward declaration
|
||||
class CC_List_Iterator_base;
|
||||
class CC_Listbase;
|
||||
|
||||
// Base classes for List template.
|
||||
// Link_base can be used by both doubly and singly linked list
|
||||
class CC_Link_base
|
||||
{
|
||||
friend class CC_Listbase;
|
||||
friend class CC_List_Iterator_base;
|
||||
public:
|
||||
CC_Link_base():f_next(NULL),f_prev(NULL) {}
|
||||
|
||||
private:
|
||||
|
||||
CC_Link_base *f_next;
|
||||
CC_Link_base *f_prev;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class CC_Listbase
|
||||
{
|
||||
friend class CC_List_Iterator_base;
|
||||
|
||||
protected:
|
||||
CC_Link_base *remove(CC_List_Iterator_base &);
|
||||
|
||||
public:
|
||||
CC_Listbase()
|
||||
: f_head (NULL), f_tail (NULL), f_length (0)
|
||||
{ }
|
||||
|
||||
void insert (CC_Link_base *); /* both insert and append is the same,
|
||||
* throw ccException() if element is NULL
|
||||
*/
|
||||
|
||||
void append (CC_Link_base *e) // in order to be Rogue Wave compatible
|
||||
{ insert(e); }
|
||||
|
||||
void prepend (CC_Link_base *); /*
|
||||
* throw ccException() if element is NULL
|
||||
*/
|
||||
|
||||
|
||||
|
||||
size_t entries() const // RW compatible
|
||||
{ return (f_length); }
|
||||
|
||||
CC_Link_base *first() const
|
||||
{ return (f_head); }
|
||||
|
||||
CC_Link_base *last() const
|
||||
{ return (f_tail); }
|
||||
|
||||
CC_Link_base *removeLast();
|
||||
CC_Link_base *removeFirst();
|
||||
|
||||
protected:
|
||||
CC_Link_base *f_head;
|
||||
CC_Link_base *f_tail;
|
||||
size_t f_length;
|
||||
};
|
||||
|
||||
|
||||
class CC_List_Iterator_base
|
||||
{
|
||||
friend class CC_Listbase;
|
||||
public:
|
||||
|
||||
CC_List_Iterator_base (CC_Listbase *list); /* will throw ccException if
|
||||
* list == NULL
|
||||
*/
|
||||
// Obtain the current link entry.
|
||||
CC_Link_base *item() const
|
||||
{ return (f_current); }
|
||||
|
||||
// Reset the iterator to the first list element.
|
||||
void reset();
|
||||
|
||||
// Increment the iterator.
|
||||
CC_Boolean operator++();
|
||||
CC_Boolean operator--();
|
||||
|
||||
protected:
|
||||
const CC_Listbase *f_list;
|
||||
CC_Link_base *f_previous;
|
||||
CC_Link_base *f_current;
|
||||
};
|
||||
|
||||
#endif /* _CC_Listbasehh */
|
||||
/* DO NOT ADD ANY LINES AFTER THIS #endif */
|
||||
221
cde/programs/dtinfo/DtMmdb/dti_cc/CC_Slist.C
Normal file
221
cde/programs/dtinfo/DtMmdb/dti_cc/CC_Slist.C
Normal file
@@ -0,0 +1,221 @@
|
||||
// $TOG: CC_Slist.C /main/5 1998/04/17 11:44:28 mgreess $
|
||||
#ifndef _CC_Slist_cc
|
||||
#define _CC_Slist_cc
|
||||
|
||||
#include "cc_exceptions.h"
|
||||
#include "CC_Slist.h"
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
template<class T>
|
||||
CC_TPtrSlist<T>::CC_TPtrSlist(const CC_TPtrSlist<T>&slist)
|
||||
{
|
||||
|
||||
destructed = FALSE;
|
||||
CC_TPtrSlistIterator<T> slist_iter( *(CC_TPtrSlist<T> *)&slist );
|
||||
|
||||
while ( slist_iter() ) {
|
||||
insert( slist_iter.key() );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------
|
||||
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) {
|
||||
|
||||
CC_TPtrSlistIterator<T> iter( *this );
|
||||
for( int i = 0; i <= pos; i++ ) {
|
||||
if ( !(++iter) ) {
|
||||
throw(CASTCCBEXCEPT ccBoundaryException(0,0,i));
|
||||
}
|
||||
}
|
||||
|
||||
T *key_val = iter.key();
|
||||
CC_Link<T> *elem = (CC_Link<T> *)CC_Listbase::remove( iter );
|
||||
delete elem;
|
||||
|
||||
return key_val;
|
||||
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
template<class T>
|
||||
T *CC_TPtrSlist<T>::find(const T* elem) const
|
||||
{
|
||||
CC_TPtrSlistIterator<T> iter( *(CC_TPtrSlist<T> *)this );
|
||||
|
||||
while ( iter() ) {
|
||||
if ( *(iter.key()) == *elem )
|
||||
return (iter.key());
|
||||
}
|
||||
|
||||
return ( NULL );
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
template<class T>
|
||||
T *CC_TPtrSlist<T>::find(CC_Boolean (*testFunc)(T*, void *),
|
||||
void *d) const
|
||||
{
|
||||
CC_TPtrSlistIterator<T> iter( *(CC_TPtrSlist<T> *)this );
|
||||
while ( iter() ) {
|
||||
if ( testFunc( iter.key(), d ) ) {
|
||||
return ( iter.key() );
|
||||
}
|
||||
}
|
||||
|
||||
return ( NULL );
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
template<class T>
|
||||
CC_Boolean CC_TPtrSlist<T>::contains(const T *elem) const
|
||||
{
|
||||
CC_TPtrSlistIterator<T> iter( *(CC_TPtrSlist<T> *)this );
|
||||
while (iter()) {
|
||||
if ( *(iter.key()) == *elem )
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
template<class T>
|
||||
T *CC_TPtrSlist<T>::remove(const T *elem)
|
||||
{
|
||||
CC_TPtrSlistIterator<T> iter( *this );
|
||||
while (iter()) {
|
||||
if ( *(iter.key()) == *elem ) {
|
||||
CC_Link<T> *key_rec = (CC_Link<T> *)CC_Listbase::remove( iter );
|
||||
T *ret = key_rec->f_element;
|
||||
delete key_rec; /* since key_rec does not allocate any memory for
|
||||
* f_element, it is ok to delete key_rec
|
||||
*/
|
||||
|
||||
return(ret);
|
||||
}
|
||||
}
|
||||
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
template <class T>
|
||||
CC_TPtrSlist<T>::~CC_TPtrSlist()
|
||||
{
|
||||
if ( !destructed ) {
|
||||
CC_TPtrSlistIterator<T> iter(*this);
|
||||
if ( ++iter ) {
|
||||
while (1) {
|
||||
CC_Link<T> *elem = (CC_Link<T> *)CC_Listbase::remove( (CC_List_Iterator_base &)iter );
|
||||
if ( elem ) {
|
||||
delete elem;
|
||||
}
|
||||
else { break; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
template <class T>
|
||||
void CC_TPtrSlist<T>::clearAndDestroy()
|
||||
{
|
||||
destructed = TRUE;
|
||||
CC_TPtrSlistIterator<T> iter(*this);
|
||||
if ( ++iter ) {
|
||||
while (1) {
|
||||
CC_Link<T> *elem = (CC_Link<T> *)CC_Listbase::remove( (CC_List_Iterator_base &)iter );
|
||||
if ( elem ) {
|
||||
T *temp_elem = elem->f_element;
|
||||
delete temp_elem;
|
||||
elem->f_element = NULL; // prevent further destruction on the pointer
|
||||
delete elem;
|
||||
}
|
||||
else { break; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
template<class T>
|
||||
void CC_TPtrSlist<T>::clear()
|
||||
{
|
||||
CC_TPtrSlistIterator<T> iter(*this);
|
||||
if ( ++iter ) {
|
||||
while (1) {
|
||||
CC_Link<T> *elem = (CC_Link<T> *)CC_Listbase::remove( (CC_List_Iterator_base &)iter );
|
||||
if ( elem ) {
|
||||
elem->f_element = 0;
|
||||
delete elem;
|
||||
}
|
||||
else { break; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
template<class T>
|
||||
CC_TValSlist<T>::CC_TValSlist(const CC_TValSlist<T> &sval_list)
|
||||
{
|
||||
CC_TValSlistIterator<T> slist_val_iter( *(CC_TValSlist<T> *)&sval_list );
|
||||
while ( ++slist_val_iter ) {
|
||||
append( slist_val_iter.key() );
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
template <class T>
|
||||
CC_TValSlist<T>::~CC_TValSlist()
|
||||
{
|
||||
CC_TValSlistIterator<T> iter( *this );
|
||||
if ( ++iter ) {
|
||||
while (1) {
|
||||
CC_Link<T> *elem = (CC_Link<T> *)CC_Listbase::remove( (CC_List_Iterator_base &)iter );
|
||||
if ( elem ) {
|
||||
if ( elem->f_element ) {
|
||||
T *temp_elem = elem->f_element;
|
||||
delete temp_elem;
|
||||
}
|
||||
delete elem;
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
template <class T>
|
||||
T CC_TValSlistIterator<T>::key() const
|
||||
{
|
||||
CC_Link<T> *link_item = (CC_Link<T> *) CC_List_Iterator_base::item();
|
||||
if ( link_item ) {
|
||||
return ( *(link_item->f_element) );
|
||||
}
|
||||
else {
|
||||
throw (CASTCCEXCEPT ccException() );
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* _CC_Slist_cc */
|
||||
/* DO NOT ADD ANY LINES AFTER THIS #endif */
|
||||
214
cde/programs/dtinfo/DtMmdb/dti_cc/CC_Slist.h
Normal file
214
cde/programs/dtinfo/DtMmdb/dti_cc/CC_Slist.h
Normal file
@@ -0,0 +1,214 @@
|
||||
/* $XConsortium: CC_Slist.h /main/6 1996/08/21 15:48:46 drk $ */
|
||||
#ifndef __CC_Slist_h
|
||||
#define __CC_Slist_h
|
||||
|
||||
#include "CC_Listbase.h"
|
||||
|
||||
template <class T> class CC_TPtrSlist;
|
||||
template <class T> class CC_TPtrSlistIterator;
|
||||
template <class T> class CC_TPtrDlist;
|
||||
template <class T> class CC_TPtrDlistIterator;
|
||||
template <class T> class CC_TValSlist;
|
||||
template <class T> class CC_TValSlistIterator;
|
||||
template <class T> class Stack;
|
||||
|
||||
|
||||
template <class T>
|
||||
class CC_Link : private CC_Link_base
|
||||
{
|
||||
friend class CC_TPtrSlist<T>;
|
||||
friend class CC_TPtrSlistIterator<T>;
|
||||
friend class CC_TPtrDlist<T>;
|
||||
friend class CC_TPtrDlistIterator<T>;
|
||||
friend class CC_TValSlist<T>;
|
||||
friend class CC_TValSlistIterator<T>;
|
||||
friend class Stack<T>;
|
||||
|
||||
private:
|
||||
CC_Link (T *element)
|
||||
: f_element (element)
|
||||
{ }
|
||||
|
||||
T* f_element;
|
||||
};
|
||||
|
||||
|
||||
template <class T> class CC_List_Iterator;
|
||||
|
||||
template <class T>
|
||||
class CC_TPtrSlist : public CC_Listbase
|
||||
{
|
||||
|
||||
//template <class T> friend class CC_List_Iterator;
|
||||
friend class CC_List_Iterator<T>;
|
||||
|
||||
protected:
|
||||
CC_Boolean destructed;
|
||||
|
||||
// Inherit public members from CC_Listbase
|
||||
/*
|
||||
* insert
|
||||
* append
|
||||
* prepend
|
||||
* entries
|
||||
* first, last
|
||||
* removeLast, removeFirst
|
||||
*/
|
||||
|
||||
public:
|
||||
CC_TPtrSlist(const CC_TPtrSlist<T> &);
|
||||
|
||||
CC_TPtrSlist() { destructed = FALSE; }
|
||||
~CC_TPtrSlist();
|
||||
|
||||
virtual void clearAndDestroy();
|
||||
virtual void clear(); /* clear only removes item, but not calling
|
||||
* individual item's destructor
|
||||
*/
|
||||
|
||||
void prepend(T* element)
|
||||
{ CC_Listbase::prepend (new CC_Link<T> (element)); }
|
||||
|
||||
void append(T* element)
|
||||
{ CC_Listbase::append (new CC_Link<T> (element)); }
|
||||
|
||||
void insert(T* element)
|
||||
{ CC_Listbase::append (new CC_Link<T> (element)); }
|
||||
|
||||
T* at(size_t pos) const; /* throw boundaryException
|
||||
* if list size is smaller than pos
|
||||
*/
|
||||
|
||||
T* removeAt(size_t pos); /* throw boundaryException
|
||||
* if list size is smaller than pos
|
||||
*/
|
||||
T* removeLast() {
|
||||
CC_Link<T> *t = (CC_Link<T> *)(CC_Listbase::removeLast());
|
||||
if ( t ) {
|
||||
T * ret = t->f_element;
|
||||
delete t;
|
||||
return(ret);
|
||||
}
|
||||
else return(NULL);
|
||||
}
|
||||
|
||||
T* removeFirst() {
|
||||
CC_Link<T> *t = (CC_Link<T> *)(CC_Listbase::removeFirst());
|
||||
if ( t ) {
|
||||
T *ret = t->f_element;
|
||||
delete t;
|
||||
return (ret);
|
||||
}
|
||||
else return(NULL);
|
||||
}
|
||||
|
||||
T* first() const
|
||||
{
|
||||
CC_Link<T> *t = (CC_Link<T> *)(CC_Listbase::first());
|
||||
if (t) { return( t->f_element ); }
|
||||
else return(NULL);
|
||||
}
|
||||
|
||||
T* last() const
|
||||
{
|
||||
CC_Link<T> *t = (CC_Link<T> *)(CC_Listbase::last());
|
||||
if (t) { return( t->f_element ); }
|
||||
else return(NULL);
|
||||
}
|
||||
|
||||
T* find(const T*) const;
|
||||
T* find(CC_Boolean (*)(T*, void*), void*) const;
|
||||
|
||||
CC_Boolean contains(const T*) const;
|
||||
T* remove(const T*);
|
||||
|
||||
operator CC_Listbase *() { return(this); }
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
template <class T>
|
||||
class CC_TPtrSlistIterator : public CC_List_Iterator_base
|
||||
{
|
||||
friend class CC_TPtrSlist<T>;
|
||||
|
||||
/*
|
||||
Inherit all the public/protected member from CC_List_Iterator_base
|
||||
reset;
|
||||
operator++
|
||||
*/
|
||||
public:
|
||||
|
||||
CC_TPtrSlistIterator (CC_TPtrSlist<T> &list)
|
||||
: CC_List_Iterator_base ( (CC_Listbase *)&list)
|
||||
{ }
|
||||
|
||||
T* key() const
|
||||
{
|
||||
CC_Link<T> *link_item = (CC_Link<T> *) CC_List_Iterator_base::item();
|
||||
if ( link_item ) {
|
||||
return ( link_item->f_element );
|
||||
}
|
||||
else {
|
||||
return(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
T *operator()()
|
||||
{
|
||||
if ( ++(*this) ) { return( key() ); }
|
||||
else { return(NULL); }
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
template <class T>
|
||||
class CC_TValSlist : public CC_Listbase
|
||||
{
|
||||
|
||||
// inherit entries from CC_Listbase
|
||||
|
||||
public:
|
||||
CC_TValSlist(const CC_TValSlist<T>&);
|
||||
|
||||
CC_TValSlist() {}
|
||||
~CC_TValSlist();
|
||||
void append( const T &t) { /* copies the content of t, also
|
||||
* assumes the copy constructor for type T
|
||||
* exists
|
||||
*/
|
||||
|
||||
T *new_element = new T( t );
|
||||
CC_Listbase::append(new CC_Link<T>((T *)new_element));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class CC_TValSlistIterator:public CC_List_Iterator_base
|
||||
{
|
||||
|
||||
/* inherit public member from CC_List_Iterator_base
|
||||
* Boolean operator++()
|
||||
*/
|
||||
|
||||
public:
|
||||
CC_TValSlistIterator (CC_TValSlist<T> &list)
|
||||
: CC_List_Iterator_base ( (CC_Listbase *)&list)
|
||||
{}
|
||||
|
||||
T key() const; // Throw ccException if link is undefined
|
||||
|
||||
};
|
||||
|
||||
|
||||
#ifdef EXPAND_TEMPLATES
|
||||
#include "CC_Slist.C"
|
||||
#endif
|
||||
|
||||
#endif /* __CC_Slist_h */
|
||||
/* DO NOT ADD ANY LINES AFTER THIS #endif */
|
||||
54
cde/programs/dtinfo/DtMmdb/dti_cc/CC_Stack.C
Normal file
54
cde/programs/dtinfo/DtMmdb/dti_cc/CC_Stack.C
Normal file
@@ -0,0 +1,54 @@
|
||||
// $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 );
|
||||
}
|
||||
34
cde/programs/dtinfo/DtMmdb/dti_cc/CC_Stack.h
Normal file
34
cde/programs/dtinfo/DtMmdb/dti_cc/CC_Stack.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/* $XConsortium: CC_Stack.h /main/4 1996/10/08 19:23:19 cde-hal $ */
|
||||
#ifndef _Stack_hh
|
||||
#define _Stack_hh
|
||||
|
||||
#include "Exceptions.hh"
|
||||
#include "CC_Slist.h"
|
||||
|
||||
template <class T> class Stack: public Destructable
|
||||
{
|
||||
|
||||
public:
|
||||
Stack (); /* This is a value stack, ie an assignment operator
|
||||
* for T is assumed */
|
||||
|
||||
~Stack ();
|
||||
|
||||
public:
|
||||
T pop ();
|
||||
void push (const T);
|
||||
T& top () const;
|
||||
int entries() const
|
||||
{
|
||||
return( Items->entries() ); //ie no. of elements in the stack
|
||||
}
|
||||
int empty() const {
|
||||
return( Items->entries() == 0 );
|
||||
}
|
||||
|
||||
private:
|
||||
CC_TValSlist<T> *Items;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
42
cde/programs/dtinfo/DtMmdb/dti_cc/CC_String.C
Normal file
42
cde/programs/dtinfo/DtMmdb/dti_cc/CC_String.C
Normal file
@@ -0,0 +1,42 @@
|
||||
// $XConsortium: CC_String.cc /main/3 1996/06/11 16:55:54 cde-hal $
|
||||
#include "CC_String.h"
|
||||
#include <ctype.h>
|
||||
|
||||
#include "utility/atoi_fast.h"
|
||||
|
||||
unsigned int
|
||||
CC_String::hash() const
|
||||
{
|
||||
static atoi_fast converter(65535, 256);
|
||||
return converter.atoi(f_string);
|
||||
}
|
||||
|
||||
CC_String::CC_String (const CC_String& x)
|
||||
{
|
||||
f_string = strdup(x.f_string);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------
|
||||
int
|
||||
CC_String::compareTo(const char *str, caseCompare CaseSensitive ) const
|
||||
{
|
||||
if ( CaseSensitive == exact ) {
|
||||
return (strcmp(f_string, str));
|
||||
}
|
||||
else {
|
||||
const char *ptr1 = f_string;
|
||||
const char *ptr2 = str;
|
||||
for ( ; tolower(*ptr1) == tolower(*ptr2) ; ptr1++, ptr2++ ) {
|
||||
if ( *ptr1 == '\0' ) {
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
|
||||
return ( tolower(*ptr1) - tolower(*ptr2) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
61
cde/programs/dtinfo/DtMmdb/dti_cc/CC_String.h
Normal file
61
cde/programs/dtinfo/DtMmdb/dti_cc/CC_String.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/* $XConsortium: CC_String.h /main/5 1996/08/21 15:48:50 drk $ */
|
||||
#ifndef _CC_STRING_H_
|
||||
#define _CC_STRING_H_
|
||||
|
||||
#include <string.h>
|
||||
#include "dti_cc/types.h"
|
||||
|
||||
class CC_String {
|
||||
public: // functions
|
||||
|
||||
CC_String (const CC_String& x);
|
||||
|
||||
CC_String (const char *string)
|
||||
{
|
||||
f_string = new char[strlen(string) + 1];
|
||||
strcpy (f_string, string);
|
||||
}
|
||||
|
||||
CC_String()
|
||||
{
|
||||
f_string = NULL;
|
||||
}
|
||||
|
||||
virtual ~CC_String () { delete f_string; }
|
||||
|
||||
CC_Boolean isNull() const {
|
||||
return( f_string[0] == '\0' );
|
||||
}
|
||||
|
||||
unsigned int hash() const; /* This returns a hash value
|
||||
* used by the hash funcion
|
||||
*/
|
||||
|
||||
size_t length() const { /* Used strlen, so expect string terminated by
|
||||
* \0. The library in RW takes care of non-null
|
||||
* terminated string. I assume this is not
|
||||
* the case here.
|
||||
*/
|
||||
return(strlen(f_string));
|
||||
}
|
||||
|
||||
enum caseCompare { exact, ignoreCase };
|
||||
int compareTo(const char *, caseCompare = exact) const;
|
||||
int compareTo(const CC_String &cs, caseCompare CaseSensitive = exact) const
|
||||
{
|
||||
return(compareTo((const char *)cs, CaseSensitive));
|
||||
}
|
||||
|
||||
CC_Boolean operator ==(const CC_String &k) const
|
||||
{
|
||||
return (compareTo(k) == 0) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
operator const char *() const { return f_string; }
|
||||
const char *data() const { return f_string; }
|
||||
|
||||
private:
|
||||
char *f_string;
|
||||
};
|
||||
|
||||
#endif
|
||||
33
cde/programs/dtinfo/DtMmdb/dti_cc/CC_Tokenizer.C
Normal file
33
cde/programs/dtinfo/DtMmdb/dti_cc/CC_Tokenizer.C
Normal file
@@ -0,0 +1,33 @@
|
||||
// $XConsortium: CC_Tokenizer.C /main/5 1996/11/21 19:47:27 drk $
|
||||
#include <string.h>
|
||||
#include "CC_Tokenizer.h"
|
||||
|
||||
//--------------------------------------------------------------
|
||||
CC_Tokenizer::CC_Tokenizer( const CC_String &s )
|
||||
{
|
||||
str_ = new char [s.length()+1];
|
||||
strcpy(str_, s.data() );
|
||||
current_ptr = str_;
|
||||
touched = FALSE;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------
|
||||
CC_Boolean
|
||||
CC_Tokenizer::operator()()
|
||||
{
|
||||
|
||||
if ( !touched ) {
|
||||
current_ptr = _XStrtok(str_, " \t\n", strtok_buf);
|
||||
touched = TRUE;
|
||||
}
|
||||
else {
|
||||
current_ptr = _XStrtok(NULL, " \t\n", strtok_buf);
|
||||
}
|
||||
|
||||
return ( current_ptr != NULL );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
39
cde/programs/dtinfo/DtMmdb/dti_cc/CC_Tokenizer.h
Normal file
39
cde/programs/dtinfo/DtMmdb/dti_cc/CC_Tokenizer.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/* $XConsortium: CC_Tokenizer.h /main/4 1996/11/04 13:35:14 drk $ */
|
||||
#ifndef __CC_Token_h
|
||||
#define __CC_Token_h
|
||||
|
||||
#include "CC_String.h"
|
||||
|
||||
#define X_INCLUDE_STRING_H
|
||||
#define XOS_USE_NO_LOCKING
|
||||
#include <X11/Xos_r.h>
|
||||
|
||||
class CC_Tokenizer {
|
||||
|
||||
private:
|
||||
char *current_ptr;
|
||||
char *str_;
|
||||
CC_Boolean touched;
|
||||
_Xstrtokparams strtok_buf;
|
||||
|
||||
public:
|
||||
CC_Tokenizer(const CC_String & );
|
||||
~CC_Tokenizer() { delete str_; }
|
||||
|
||||
|
||||
/* Here is an example to use the code
|
||||
* CC_String b("This is a string");
|
||||
* CC_Tokenizer next( b );
|
||||
* while ( next() ) {
|
||||
* cout << next.data() << endl;
|
||||
* }
|
||||
*/
|
||||
|
||||
CC_Boolean operator()(); /* returns TRUE if next token exists,
|
||||
* FALSE if otherwise
|
||||
*/
|
||||
const char *data() { return(current_ptr); } /* returns the current token */
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
27
cde/programs/dtinfo/DtMmdb/dti_cc/cc_exceptions.C
Normal file
27
cde/programs/dtinfo/DtMmdb/dti_cc/cc_exceptions.C
Normal file
@@ -0,0 +1,27 @@
|
||||
// $XConsortium: cc_exceptions.C /main/4 1996/08/21 15:48:54 drk $
|
||||
|
||||
#include "dti_cc/cc_exceptions.h"
|
||||
|
||||
ostream& ccException::asciiOut(ostream& out)
|
||||
{
|
||||
out << "ccException::asciiOut() called\n";
|
||||
return out;
|
||||
}
|
||||
|
||||
ostream& ccStringException::asciiOut(ostream& out)
|
||||
{
|
||||
out << msg << "\n";
|
||||
return out;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////
|
||||
//////////////////////////////////////////
|
||||
|
||||
ostream& ccBoundaryException::asciiOut(ostream& out)
|
||||
{
|
||||
cerr << low << "\t";
|
||||
cerr << high << "\t";
|
||||
cerr << index << "\n";
|
||||
return out;
|
||||
}
|
||||
|
||||
75
cde/programs/dtinfo/DtMmdb/dti_cc/cc_exceptions.h
Normal file
75
cde/programs/dtinfo/DtMmdb/dti_cc/cc_exceptions.h
Normal file
@@ -0,0 +1,75 @@
|
||||
/* $TOG: cc_exceptions.h /main/5 1998/04/17 11:44:44 mgreess $ */
|
||||
|
||||
#ifndef _cc_exception_h
|
||||
#define _cc_exception_h 1
|
||||
|
||||
#include <fstream.h>
|
||||
#include "Exceptions.hh"
|
||||
|
||||
#define END_TRY end_try
|
||||
|
||||
#include <X11/Xosdefs.h>
|
||||
#include <errno.h>
|
||||
#ifdef X_NOT_STDC_ENV
|
||||
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
|
||||
{
|
||||
public:
|
||||
DECLARE_EXCEPTION(ccException, Exception);
|
||||
|
||||
virtual ~ccException() {};
|
||||
|
||||
virtual ostream& asciiOut(ostream&);
|
||||
|
||||
friend ostream& operator <<(ostream& out, ccException& e) {
|
||||
return e.asciiOut(out);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class ccStringException : public ccException
|
||||
{
|
||||
protected:
|
||||
char* msg;
|
||||
|
||||
public:
|
||||
DECLARE_EXCEPTION(ccStringException, ccException);
|
||||
|
||||
ccStringException(char* m) : msg(m) {};
|
||||
~ccStringException() {};
|
||||
|
||||
virtual ostream& asciiOut(ostream&);
|
||||
};
|
||||
|
||||
class ccBoundaryException : public ccException
|
||||
{
|
||||
|
||||
protected:
|
||||
int low;
|
||||
int high;
|
||||
int index;
|
||||
|
||||
public:
|
||||
DECLARE_EXCEPTION(ccBoundaryException, ccException);
|
||||
|
||||
ccBoundaryException(int l, int h, int i) :
|
||||
low(l), high(h), index(i) {};
|
||||
~ccBoundaryException() {};
|
||||
|
||||
virtual ostream& asciiOut(ostream&);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
281
cde/programs/dtinfo/DtMmdb/dti_cc/cc_hdict.C
Normal file
281
cde/programs/dtinfo/DtMmdb/dti_cc/cc_hdict.C
Normal file
@@ -0,0 +1,281 @@
|
||||
// $TOG: cc_hdict.C /main/5 1998/04/17 11:45:00 mgreess $
|
||||
|
||||
#include "dti_cc/cc_exceptions.h"
|
||||
|
||||
#if !defined(__osf__) && !defined(linux)
|
||||
template <class K, class V> CC_Boolean kv_pair<K, V>::f_needRemove = FALSE;
|
||||
#endif
|
||||
|
||||
template <class K, class V>
|
||||
kv_pair<K, V>::~kv_pair()
|
||||
{
|
||||
if ( f_needRemove == TRUE ) {
|
||||
delete f_key;
|
||||
delete f_value;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
template <class K, class V>
|
||||
ostream& kv_pair<K, V>::print(ostream& out)
|
||||
{
|
||||
return out << *f_key << " " << *f_value << "\n";
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class K, class V>
|
||||
unsigned int kv_pair<K, V>::operator==(const kv_pair<K, V>& kv)
|
||||
{
|
||||
if ( f_key == 0 || kv.f_key == 0 )
|
||||
throw(ccStringException("kv_pair::operator==(): null pointer(s)."));
|
||||
|
||||
return ( *f_key == (*kv.f_key) ) ? 1 : 0;
|
||||
}
|
||||
|
||||
///////////////////////////////////
|
||||
//
|
||||
///////////////////////////////////
|
||||
|
||||
template <class K, class V>
|
||||
hashTable<K,V>::hashTable(const hashTable<K, V>& h) :
|
||||
f_hash_func_ptr(h.f_hash_func_ptr), f_buckets(h.f_buckets),
|
||||
f_items(h.f_items)
|
||||
{
|
||||
cerr << "Warning: hashTable(const hashTable&) called" << endl;
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
template <class K, class V>
|
||||
hashTable<K,V>::hashTable(unsigned (*f)(const K&), size_t init_bucket_num) :
|
||||
f_hash_func_ptr(f), f_buckets(init_bucket_num),
|
||||
f_items(0)
|
||||
{
|
||||
}
|
||||
|
||||
template <class K, class V>
|
||||
hashTable<K,V>::~hashTable()
|
||||
{
|
||||
CC_TPtrSlist<kv_pair<K, V> > * b = 0;
|
||||
kv_pair<K, V> * r = 0;
|
||||
|
||||
for (int i=0; i<f_buckets.length(); i++ ) {
|
||||
|
||||
b = f_buckets[i];
|
||||
|
||||
if ( b ) {
|
||||
while ( (r = b -> removeFirst()) )
|
||||
delete r;
|
||||
|
||||
delete b;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class K, class V>
|
||||
void hashTable<K,V>::clearAndDestroy()
|
||||
{
|
||||
kv_pair<K, V>::f_needRemove = TRUE;
|
||||
|
||||
CC_TPtrSlist<kv_pair<K, V> >* b = 0;
|
||||
|
||||
for (int i=0; i<f_buckets.length(); i++ ) {
|
||||
|
||||
b = f_buckets[i];
|
||||
if ( b ) {
|
||||
b -> clearAndDestroy();
|
||||
delete b;
|
||||
f_buckets[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
f_items = 0;
|
||||
|
||||
kv_pair<K, V>::f_needRemove = FALSE;
|
||||
}
|
||||
|
||||
template <class K, class V>
|
||||
CC_Boolean hashTable<K,V>::contains(const K* k) const
|
||||
{
|
||||
if ( findValue(k) )
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
|
||||
}
|
||||
|
||||
template <class K, class V>
|
||||
kv_pair<K, V>* hashTable<K,V>::_find(const K* k) const
|
||||
{
|
||||
size_t i = (*f_hash_func_ptr)(*k) % f_buckets.length();
|
||||
|
||||
CC_TPtrSlist<kv_pair<K, V> >* b = f_buckets[i];
|
||||
|
||||
if ( b == 0 )
|
||||
return 0;
|
||||
|
||||
kv_pair<K, V> key((K*)k);
|
||||
|
||||
return b -> find(&key);
|
||||
}
|
||||
|
||||
template <class K, class V>
|
||||
V* hashTable<K,V>::findValue(const K* k) const
|
||||
{
|
||||
kv_pair<K, V>* p = _find(k);
|
||||
if ( p )
|
||||
return p -> f_value;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <class K, class V>
|
||||
K* hashTable<K,V>::findKeyAndValue(const K* k, V*& v) const
|
||||
{
|
||||
kv_pair<K, V>* p = _find(k);
|
||||
if ( p ) {
|
||||
v = p -> f_value;
|
||||
return p -> f_key;
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <class K, class V>
|
||||
void hashTable<K,V>::insertKeyAndValue(K* k, V* v)
|
||||
{
|
||||
size_t i = (*f_hash_func_ptr)(*k) % f_buckets.length();
|
||||
|
||||
CC_TPtrSlist<kv_pair<K, V> >* b = f_buckets[i];
|
||||
|
||||
if ( b == 0 ) {
|
||||
f_buckets[i] = new CC_TPtrSlist<kv_pair<K, V> >;
|
||||
}
|
||||
|
||||
kv_pair<K, V>* p = new kv_pair<K, V>(k, v);
|
||||
f_buckets[i] -> insert(p);
|
||||
|
||||
f_items ++;
|
||||
}
|
||||
|
||||
template <class K, class V>
|
||||
K* hashTable<K,V>::remove(const K* k)
|
||||
{
|
||||
size_t i = (*f_hash_func_ptr)(*k) % f_buckets.length();
|
||||
|
||||
CC_TPtrSlist<kv_pair<K, V> >* b = f_buckets[i];
|
||||
|
||||
if ( b == 0 )
|
||||
return 0;
|
||||
|
||||
kv_pair<K, V> key((K*)k, 0);
|
||||
kv_pair<K, V>* result = b -> remove(&key);
|
||||
|
||||
if ( result == 0 )
|
||||
return 0;
|
||||
|
||||
K* kr = result -> f_key;
|
||||
|
||||
delete result;
|
||||
|
||||
f_items --;
|
||||
|
||||
return kr;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
template <class K, class V>
|
||||
ostream& hashTable<K,V>::print(ostream& out)
|
||||
{
|
||||
CC_TPtrSlist<kv_pair<K, V> >* b = 0;
|
||||
|
||||
for (int i=0; i<f_buckets.length(); i++ ) {
|
||||
|
||||
b = f_buckets[i];
|
||||
if ( b ) {
|
||||
cerr << "bucket num = " << i << "\n";
|
||||
|
||||
CC_TPtrSlistIterator<kv_pair<K, V> > next(*b);
|
||||
|
||||
while (++next) {
|
||||
out << ' ' << *next.key() ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////
|
||||
template <class K, class V>
|
||||
hashTableIterator<K,V>::hashTableIterator(hashTable<K, V>& b) :
|
||||
f_bucket_num(0), f_pos(0), f_rec(0), f_hashTable(b)
|
||||
{
|
||||
}
|
||||
|
||||
template <class K, class V>
|
||||
hashTableIterator<K,V>::~hashTableIterator()
|
||||
{
|
||||
}
|
||||
|
||||
template <class K, class V>
|
||||
CC_Boolean hashTableIterator<K,V>::_findNonEmptyBucket()
|
||||
{
|
||||
CC_TPtrSlist<kv_pair<K, V> >* b = 0;
|
||||
|
||||
for (; f_bucket_num<f_hashTable.f_buckets.length(); f_bucket_num++ ) {
|
||||
if ( (b=f_hashTable.f_buckets[f_bucket_num]) && b->entries() > 0 ) {
|
||||
f_pos = 0;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
template <class K, class V>
|
||||
CC_Boolean hashTableIterator<K,V>::operator++()
|
||||
{
|
||||
if ( f_rec == 0 ) { // first call to this op.
|
||||
if ( _findNonEmptyBucket() == FALSE )
|
||||
return FALSE;
|
||||
|
||||
} else {
|
||||
if ( _findNextRecord() == FALSE ) {
|
||||
f_bucket_num++;
|
||||
if ( _findNonEmptyBucket() == FALSE )
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
//fprintf(stderr, "in operator++: f_bucket_num= %d, f_pos = %d\n",
|
||||
//f_bucket_num, f_pos);
|
||||
|
||||
f_rec = f_hashTable.f_buckets[f_bucket_num] -> at(f_pos);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
template <class K, class V>
|
||||
CC_Boolean hashTableIterator<K,V>::_findNextRecord()
|
||||
{
|
||||
f_pos++;
|
||||
|
||||
//fprintf(stderr, "f_bucket_num= %d, f_pos = %d, entries() = %d\n", f_bucket_num, f_pos, f_hashTable.f_buckets[f_bucket_num] -> entries() );
|
||||
|
||||
if ( f_hashTable.f_buckets[f_bucket_num] -> entries() <= f_pos )
|
||||
return FALSE;
|
||||
else
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
template <class K, class V>
|
||||
K* hashTableIterator<K,V>::key()
|
||||
{
|
||||
return f_rec -> f_key;
|
||||
}
|
||||
|
||||
template <class K, class V>
|
||||
V* hashTableIterator<K,V>::value() const
|
||||
{
|
||||
return f_rec -> f_value;
|
||||
}
|
||||
|
||||
109
cde/programs/dtinfo/DtMmdb/dti_cc/cc_hdict.h
Normal file
109
cde/programs/dtinfo/DtMmdb/dti_cc/cc_hdict.h
Normal file
@@ -0,0 +1,109 @@
|
||||
/* $XConsortium: cc_hdict.h /main/5 1996/08/21 15:49:02 drk $ */
|
||||
|
||||
#ifndef _cc_hdict_h
|
||||
#define _cc_hdict_h 1
|
||||
|
||||
#include "dti_cc/types.h"
|
||||
#include "dti_cc/cc_pvect.h"
|
||||
#include "dti_cc/CC_Slist.h"
|
||||
|
||||
#include <iostream.h>
|
||||
|
||||
template <class K, class V>
|
||||
class kv_pair {
|
||||
public:
|
||||
|
||||
static CC_Boolean f_needRemove;
|
||||
|
||||
kv_pair(K* k, V* v = 0): f_key(k), f_value(v) {};
|
||||
~kv_pair();
|
||||
|
||||
unsigned int operator==(const kv_pair<K, V>&);
|
||||
|
||||
#ifdef DEBUG
|
||||
ostream& print(ostream&);
|
||||
friend ostream& operator<<(ostream& out, kv_pair<K, V>& kv) {
|
||||
return kv.print(out);
|
||||
}
|
||||
#endif
|
||||
|
||||
K* f_key;
|
||||
V* f_value;
|
||||
};
|
||||
|
||||
#define DEFAULT_BUCKET_NUM 30
|
||||
|
||||
template <class K, class V> class hashTableIterator;
|
||||
|
||||
template <class K, class V> class hashTable
|
||||
{
|
||||
//template <class K, class V>
|
||||
//friend class hashTableIterator;
|
||||
|
||||
friend class hashTableIterator<K, V>;
|
||||
|
||||
protected:
|
||||
pointer_vector<CC_TPtrSlist<kv_pair<K, V> > > f_buckets;
|
||||
unsigned (*f_hash_func_ptr)(const K&);
|
||||
size_t f_items;
|
||||
|
||||
protected:
|
||||
kv_pair<K, V>* _find(const K* k) const;
|
||||
|
||||
public:
|
||||
hashTable(const hashTable <K,V> &);
|
||||
hashTable(unsigned (*)(const K&),
|
||||
size_t init_bucket_num = DEFAULT_BUCKET_NUM
|
||||
);
|
||||
~hashTable();
|
||||
|
||||
void clearAndDestroy();
|
||||
|
||||
size_t entries() { return f_items; };
|
||||
|
||||
CC_Boolean contains(const K*) const;
|
||||
|
||||
V* findValue(const K*) const;
|
||||
K* findKeyAndValue(const K*, V*&) const;
|
||||
|
||||
void insertKeyAndValue(K*, V*);
|
||||
|
||||
K* remove(const K*);
|
||||
|
||||
#ifdef DEBUG
|
||||
ostream& print(ostream& out);
|
||||
|
||||
friend ostream& operator<<(ostream& out, hashTable<K, V>& ht) {
|
||||
return ht.print(out);
|
||||
};
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
template <class K, class V>
|
||||
class hashTableIterator
|
||||
{
|
||||
protected:
|
||||
size_t f_bucket_num;
|
||||
size_t f_pos;
|
||||
kv_pair<K, V>* f_rec;
|
||||
hashTable<K, V>& f_hashTable;
|
||||
|
||||
CC_Boolean _findNonEmptyBucket();
|
||||
CC_Boolean _findNextRecord();
|
||||
|
||||
public:
|
||||
hashTableIterator(hashTable<K, V>&);
|
||||
~hashTableIterator();
|
||||
|
||||
CC_Boolean operator++();
|
||||
K* key();
|
||||
V* value() const;
|
||||
};
|
||||
|
||||
#ifdef EXPAND_TEMPLATES
|
||||
#include "cc_hdict.C"
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
19
cde/programs/dtinfo/DtMmdb/dti_cc/cc_povec.C
Normal file
19
cde/programs/dtinfo/DtMmdb/dti_cc/cc_povec.C
Normal file
@@ -0,0 +1,19 @@
|
||||
// $XConsortium: cc_povec.cc /main/3 1996/06/11 16:56:44 cde-hal $
|
||||
|
||||
template <class T>
|
||||
dlist_array<T>::dlist_array(const dlist_array<T>& da)
|
||||
{
|
||||
cerr << "Warning: dlist_array(const dlist_array&) called" << endl ;
|
||||
exit (-1);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
dlist_array<T>::dlist_array(size_t)
|
||||
{
|
||||
}
|
||||
|
||||
template <class T>
|
||||
dlist_array<T>::~dlist_array()
|
||||
{
|
||||
}
|
||||
|
||||
37
cde/programs/dtinfo/DtMmdb/dti_cc/cc_povec.h
Normal file
37
cde/programs/dtinfo/DtMmdb/dti_cc/cc_povec.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/* $XConsortium: cc_povec.h /main/5 1996/08/21 15:49:07 drk $ */
|
||||
|
||||
#ifndef _cc_dlist_array_h
|
||||
#define _cc_dlist_array_h
|
||||
|
||||
#include "dti_cc/CC_Dlist.h"
|
||||
|
||||
template <class T>
|
||||
class dlist_array : public CC_TPtrDlist<T>
|
||||
{
|
||||
protected:
|
||||
|
||||
public:
|
||||
dlist_array(const dlist_array<T>&);
|
||||
dlist_array(size_t);
|
||||
virtual ~dlist_array();
|
||||
|
||||
//Get these members from CC_TPtrDlist
|
||||
/*
|
||||
size_t entries() const ;
|
||||
void clearAndDestroy();
|
||||
void prepend(T*);
|
||||
void append(T*);
|
||||
T* first() ;
|
||||
*/
|
||||
|
||||
T* operator()(size_t i) const { return at(i); };
|
||||
T* operator[](size_t i) const { return at(i); };
|
||||
};
|
||||
|
||||
#ifdef EXPAND_TEMPLATES
|
||||
#include "cc_povec.C"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
47
cde/programs/dtinfo/DtMmdb/dti_cc/cc_pvect.C
Normal file
47
cde/programs/dtinfo/DtMmdb/dti_cc/cc_pvect.C
Normal file
@@ -0,0 +1,47 @@
|
||||
// $TOG: cc_pvect.C /main/6 1998/04/17 11:45:20 mgreess $
|
||||
|
||||
#include "dti_cc/cc_exceptions.h"
|
||||
|
||||
template <class T>
|
||||
pointer_vector<T>::pointer_vector(const pointer_vector<T>& pv) :
|
||||
f_array(new Tptr[pv.f_size]), f_size(pv.f_size), f_items(pv.f_items)
|
||||
{
|
||||
for (int i=0; i<pv.f_size; i++ )
|
||||
f_array[i] = pv.f_array[i];
|
||||
|
||||
cerr << "Warning: pointer_vector(const pointer_vector&) called" << endl;
|
||||
exit (-1);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
pointer_vector<T>::pointer_vector(size_t n, T* t)
|
||||
: f_array(new Tptr[n]), f_size(n), f_items(0)
|
||||
{
|
||||
for ( int i=0; i<f_size; i++ )
|
||||
f_array[i] = t;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
pointer_vector<T>::~pointer_vector()
|
||||
{
|
||||
delete f_array;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
T* pointer_vector<T>::operator[](size_t i) const
|
||||
{
|
||||
if ( i<0 || i>= f_size )
|
||||
throw(CASTCCBEXCEPT ccBoundaryException(0, f_size-1, i));
|
||||
else
|
||||
return f_array[i];
|
||||
}
|
||||
|
||||
template <class T>
|
||||
T*& pointer_vector<T>::operator[](size_t i)
|
||||
{
|
||||
if ( i<0 || i>= f_size )
|
||||
throw(CASTCCBEXCEPT ccBoundaryException(0, f_size-1, i));
|
||||
else
|
||||
return f_array[i];
|
||||
}
|
||||
|
||||
39
cde/programs/dtinfo/DtMmdb/dti_cc/cc_pvect.h
Normal file
39
cde/programs/dtinfo/DtMmdb/dti_cc/cc_pvect.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/* $XConsortium: cc_pvect.h /main/6 1996/08/21 15:49:14 drk $ */
|
||||
|
||||
#ifndef _cc_pvector_h
|
||||
#define _cc_pvector_h 1
|
||||
|
||||
#include "dti_cc/types.h"
|
||||
|
||||
template <class T>
|
||||
class pointer_vector
|
||||
{
|
||||
protected:
|
||||
|
||||
typedef T *Tptr;
|
||||
|
||||
Tptr *f_array;
|
||||
size_t f_size;
|
||||
size_t f_items;
|
||||
|
||||
protected:
|
||||
|
||||
public:
|
||||
pointer_vector(const pointer_vector<T> &);
|
||||
pointer_vector(size_t, T* = 0);
|
||||
~pointer_vector();
|
||||
|
||||
T* operator[](size_t) const;
|
||||
T*& operator[](size_t);
|
||||
|
||||
// size_t entries() const { return f_items; };
|
||||
size_t length() const { return f_size; };
|
||||
};
|
||||
|
||||
#ifdef EXPAND_TEMPLATES
|
||||
#include "cc_pvect.C"
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
58
cde/programs/dtinfo/DtMmdb/dti_cc/cc_vvect.C
Normal file
58
cde/programs/dtinfo/DtMmdb/dti_cc/cc_vvect.C
Normal file
@@ -0,0 +1,58 @@
|
||||
// $XConsortium: cc_vvect.C /main/4 1996/08/21 15:49:18 drk $
|
||||
|
||||
#include "dti_cc/cc_exceptions.h"
|
||||
|
||||
template <class T>
|
||||
value_vector<T>::value_vector(const value_vector<T>& vv) :
|
||||
f_array(new T[vv.f_size]), f_size(vv.f_size)
|
||||
{
|
||||
for (int i=0; i<vv.f_size; i++ )
|
||||
f_array[i] = vv.f_array[i];
|
||||
|
||||
cerr << "WARNING: value_vector(const value_vector&) called";
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
value_vector<T>::value_vector(size_t n) :
|
||||
f_array(new T[n]), f_size(n)
|
||||
{
|
||||
}
|
||||
|
||||
template <class T>
|
||||
value_vector<T>::value_vector(size_t n, const T& t) :
|
||||
f_array(new T[n]), f_size(n)
|
||||
{
|
||||
for (int i=0; i<f_size; i++ )
|
||||
f_array[i] = t;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
value_vector<T>::~value_vector()
|
||||
{
|
||||
delete f_array;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void value_vector<T>::_grow(size_t t)
|
||||
{
|
||||
}
|
||||
|
||||
template <class T>
|
||||
T value_vector<T>::operator[](size_t i) const
|
||||
{
|
||||
if ( i<0 || i>= f_size )
|
||||
throw(ccBoundaryException(0, f_size-1, i));
|
||||
else
|
||||
return f_array[i];
|
||||
}
|
||||
|
||||
template <class T>
|
||||
T& value_vector<T>::operator[](size_t i)
|
||||
{
|
||||
if ( i<0 || i>= f_size )
|
||||
throw(ccBoundaryException(0, f_size-1, i));
|
||||
else
|
||||
return f_array[i];
|
||||
}
|
||||
|
||||
32
cde/programs/dtinfo/DtMmdb/dti_cc/cc_vvect.h
Normal file
32
cde/programs/dtinfo/DtMmdb/dti_cc/cc_vvect.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/* $XConsortium: cc_vvect.h /main/5 1996/08/21 15:49:21 drk $ */
|
||||
|
||||
#ifndef _cc_vector_h
|
||||
#define _cc_vector_h
|
||||
|
||||
template <class T> class value_vector
|
||||
{
|
||||
protected:
|
||||
T* f_array;
|
||||
size_t f_size;
|
||||
|
||||
protected:
|
||||
void _grow(size_t);
|
||||
|
||||
public:
|
||||
value_vector(const value_vector<T>&);
|
||||
|
||||
value_vector(size_t);
|
||||
value_vector(size_t, const T&);
|
||||
virtual ~value_vector();
|
||||
|
||||
T operator[](size_t) const;
|
||||
T& operator[](size_t) ;
|
||||
size_t entries() { return f_size; };
|
||||
};
|
||||
|
||||
#ifdef EXPAND_TEMPLATES
|
||||
#include "cc_vvect.C"
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
11
cde/programs/dtinfo/DtMmdb/dti_cc/hdictinit.C
Normal file
11
cde/programs/dtinfo/DtMmdb/dti_cc/hdictinit.C
Normal file
@@ -0,0 +1,11 @@
|
||||
// $XConsortium: hdictinit.C /main/4 1996/08/21 15:49:25 drk $
|
||||
|
||||
|
||||
#include "dti_cc/cc_pvect.h"
|
||||
#include "dti_cc/cc_hdict.h"
|
||||
|
||||
|
||||
typedef hashTable<int, float> _f1__;
|
||||
typedef hashTableIterator<int, float> _f2__;
|
||||
|
||||
|
||||
13
cde/programs/dtinfo/DtMmdb/dti_cc/types.h
Normal file
13
cde/programs/dtinfo/DtMmdb/dti_cc/types.h
Normal file
@@ -0,0 +1,13 @@
|
||||
/* $XConsortium: types.h /main/3 1996/06/11 16:57:30 cde-hal $ */
|
||||
|
||||
#ifndef _cc_types_h
|
||||
#define _cc_types_h 1
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
typedef unsigned int CC_Boolean;
|
||||
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
|
||||
#endif
|
||||
16
cde/programs/dtinfo/DtMmdb/dti_cc/vectinit.C
Normal file
16
cde/programs/dtinfo/DtMmdb/dti_cc/vectinit.C
Normal file
@@ -0,0 +1,16 @@
|
||||
// $XConsortium: vectinit.C /main/4 1996/08/21 15:49:30 drk $
|
||||
|
||||
#include "dti_cc/cc_povec.h"
|
||||
#include "dti_cc/cc_pvect.h"
|
||||
|
||||
|
||||
|
||||
typedef dlist_array<int> _f1;
|
||||
typedef CC_TPtrDlist<int> _f2;
|
||||
typedef CC_TPtrSlist<int> _f3;
|
||||
typedef CC_TPtrDlistIterator<int> _f4;
|
||||
typedef CC_TPtrSlistIterator<int> _f5;
|
||||
|
||||
typedef pointer_vector<int> _f6__;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user