Initial import of the CDE 2.1.30 sources from the Open Group.
This commit is contained in:
42
cde/programs/dtinfo/DtMmdb/dstr/Imakefile
Normal file
42
cde/programs/dtinfo/DtMmdb/dstr/Imakefile
Normal file
@@ -0,0 +1,42 @@
|
||||
XCOMM $XConsortium: Imakefile /main/9 1996/08/21 15:51:44 drk $
|
||||
|
||||
XCOMM ** WARNING **
|
||||
XCOMM
|
||||
XCOMM The files named here may appear in many different Imakefiles.
|
||||
XCOMM If you add or remove a file, be sure to update all locations.
|
||||
XCOMM It's unfortunate, but all this redundancy serves a purpose.
|
||||
XCOMM
|
||||
XCOMM Other possible locations are:
|
||||
XCOMM .../lib/DtMmdb/Imakefile
|
||||
XCOMM .../lib/DtMmdb/<subdir>/Imakefile
|
||||
XCOMM .../programs/dtinfo/mmdb/Imakefile
|
||||
XCOMM .../programs/dtinfo/mmdb/<subdir>/Imakefile
|
||||
|
||||
#define DoNormalLib NormalLibDtMmdb
|
||||
#define DoSharedLib SharedLibDtMmdb
|
||||
#define DoDebugLib DebugLibDtMmdb
|
||||
#define DoProfileLib ProfileLibDtMmdb
|
||||
#define LibName DtMmdb
|
||||
#define SoRev SODTMMDBREV
|
||||
#define LibHeaders NO
|
||||
#define LibCreate NO
|
||||
#define LargePICTable YES
|
||||
|
||||
#define CplusplusSource YES
|
||||
DEPEND_DEFINES = $(CXXDEPENDINCLUDES)
|
||||
|
||||
XCOMM In DtMmdb we compile as C_API sources.
|
||||
DEFINES = -DC_API
|
||||
INCLUDES = -I.. $(EXCEPTIONS_INCLUDES)
|
||||
|
||||
SRCS = set.C bset.C slist.C dlist_cell.C dlist.C heap.C \
|
||||
void_ptr_array.C void_ptr_stack.C \
|
||||
memory_pool.C dstr_test.C \
|
||||
index_agent.C token_stack.C slist_char_ptr_cell.C
|
||||
OBJS = $(SRCS:.C=.o)
|
||||
|
||||
#include <Library.tmpl>
|
||||
|
||||
SubdirLibraryRule($(OBJS))
|
||||
|
||||
DependTarget()
|
||||
455
cde/programs/dtinfo/DtMmdb/dstr/bset.C
Normal file
455
cde/programs/dtinfo/DtMmdb/dstr/bset.C
Normal file
@@ -0,0 +1,455 @@
|
||||
/*
|
||||
* $XConsortium: bset.cc /main/5 1996/07/18 14:28:37 drk $
|
||||
*
|
||||
* Copyv_right (c) 1993 HAL Computer Systems International, Ltd.
|
||||
* All v_rights reserved. Unpublished -- v_rights reserved under
|
||||
* the Copyv_right 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 "dstr/bset.h"
|
||||
|
||||
Boolean void_ls(const void* o1, const void* o2)
|
||||
{
|
||||
return (long(o1) < long(o2) ) ? true : false;
|
||||
}
|
||||
|
||||
Boolean void_eq(const void* o1, const void* o2)
|
||||
{
|
||||
return (long(o1) == long(o2) ) ? true : false;
|
||||
}
|
||||
|
||||
//**************************************************************
|
||||
//
|
||||
// a set implemented based on binary search tree data structure.
|
||||
//
|
||||
//**************************************************************
|
||||
|
||||
|
||||
bset::bset(cmp_func_ptr_t eq, cmp_func_ptr_t ls): v_setroot(0), set(eq, ls)
|
||||
{
|
||||
//assert ( eq && ls );
|
||||
}
|
||||
|
||||
bset::~bset()
|
||||
{
|
||||
delete v_setroot;
|
||||
}
|
||||
|
||||
Boolean bset::_insert(void* x, bsetnode *rt)
|
||||
{
|
||||
/*
|
||||
debug(cerr, "in bsert _insert");
|
||||
debug(cerr, int(x));
|
||||
debug(cerr, int(rt));
|
||||
*/
|
||||
|
||||
/*
|
||||
debug(cerr, int(f_cmp_func_eq));
|
||||
debug(cerr, int(f_cmp_func_ls));
|
||||
*/
|
||||
|
||||
if ( (*f_cmp_func_eq)(x, rt -> v_element) == true )
|
||||
return false;
|
||||
|
||||
if ( (*f_cmp_func_ls)(x, rt -> v_element) == true )
|
||||
if ( rt -> v_left == 0 ) {
|
||||
rt -> v_left = new bsetnode(x);
|
||||
return true;
|
||||
} else
|
||||
return _insert(x, rt -> v_left);
|
||||
else
|
||||
if ( rt -> v_right == 0 ) {
|
||||
rt -> v_right = new bsetnode(x);
|
||||
return true;
|
||||
} else
|
||||
return _insert(x, rt -> v_right);
|
||||
}
|
||||
|
||||
Boolean bset::insert(void* x)
|
||||
{
|
||||
/*
|
||||
debug(cerr, "in bsert insert");
|
||||
debug(cerr, int(f_cmp_func_eq));
|
||||
debug(cerr, int(f_cmp_func_ls));
|
||||
debug(cerr, int(this));
|
||||
debug(cerr, int(x));
|
||||
debug(cerr, int(v_setroot));
|
||||
*/
|
||||
|
||||
if ( v_setroot == 0 ) {
|
||||
v_setroot = new bsetnode(x);
|
||||
return true;
|
||||
} else {
|
||||
|
||||
//debug(cerr, "to bsert _insert");
|
||||
|
||||
return _insert(x, v_setroot);
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
// delete the min node from true rooted at rt and return its
|
||||
// v_element pointer
|
||||
/////////////////////////////////////////////////////////////
|
||||
void* bset::_remove_min(void* x, bsetnode*& rt)
|
||||
{
|
||||
if ( rt -> v_left == 0 ) {
|
||||
if ( rt -> v_right )
|
||||
return _move(rt, rt -> v_right);
|
||||
else {
|
||||
void* y = rt -> v_element;
|
||||
delete rt;
|
||||
rt = 0;
|
||||
return y;
|
||||
}
|
||||
} else
|
||||
return _remove_min(x, rt -> v_left);
|
||||
}
|
||||
|
||||
//**********************************************************************
|
||||
// move the content and pointers of node2 to node1 and remove node2
|
||||
//**********************************************************************
|
||||
void* bset::_move(bsetnode* node1, bsetnode* node2)
|
||||
{
|
||||
void* y = node1 -> v_element ;
|
||||
|
||||
node1 -> v_element = node2 -> v_element ;
|
||||
node2 -> v_element = 0;
|
||||
node1 -> v_left = node2 -> v_left ;
|
||||
node2 -> v_left = 0;
|
||||
node1 -> v_right = node2 -> v_right ;
|
||||
node2 -> v_right = 0;
|
||||
delete node2 ;
|
||||
|
||||
return y;
|
||||
}
|
||||
|
||||
void* bset::_remove(void* x, bsetnode*& rt)
|
||||
{
|
||||
if ( (*f_cmp_func_ls)(x, rt -> v_element) == true ) // v_left branch
|
||||
return _remove(x, rt -> v_left);
|
||||
else
|
||||
if ( !((*f_cmp_func_eq)(x, rt -> v_element) == true ) ) // v_right branch
|
||||
return _remove(x, rt -> v_right);
|
||||
else
|
||||
if ( rt -> v_left == 0 && rt -> v_right == 0 ) { // find the node.
|
||||
void* y = rt -> v_element ;
|
||||
delete rt;
|
||||
rt = 0;
|
||||
return y;
|
||||
} else
|
||||
if ( rt -> v_left == 0 ) {
|
||||
return _move(rt, rt -> v_right);
|
||||
} else
|
||||
if ( rt -> v_right == 0 ) {
|
||||
return _move(rt, rt -> v_left);
|
||||
} else {
|
||||
void* y = rt -> v_element ;
|
||||
rt -> v_element = _remove_min(x, rt -> v_right );
|
||||
return y;
|
||||
}
|
||||
}
|
||||
|
||||
void* bset::remove(void* x)
|
||||
{
|
||||
if ( v_setroot == 0 )
|
||||
return 0;
|
||||
else
|
||||
return _remove(x, v_setroot);
|
||||
}
|
||||
|
||||
void* bset::_member(const void* x, bsetnode *rt)
|
||||
{
|
||||
if ( rt == 0 ) {
|
||||
//debug(cerr, "member void zeor");
|
||||
return 0;
|
||||
} else if ( (*f_cmp_func_eq)(x, rt -> v_element) == true )
|
||||
return rt -> v_element;
|
||||
else if ( (*f_cmp_func_ls)(x, rt -> v_element) == true )
|
||||
return _member(x, rt -> v_left);
|
||||
else
|
||||
return _member(x, rt -> v_right);
|
||||
}
|
||||
|
||||
void* bset::member(const void* x)
|
||||
{
|
||||
/*
|
||||
debug(cerr, "member");
|
||||
debug(cerr, int(f_cmp_func_eq));
|
||||
debug(cerr, int(f_cmp_func_ls));
|
||||
debug(cerr, int(this));
|
||||
*/
|
||||
return _member(x, v_setroot);
|
||||
}
|
||||
|
||||
void bset::apply(app_func_ptr_t f)
|
||||
{
|
||||
_apply(v_setroot, f);
|
||||
}
|
||||
|
||||
void bset::_apply(bsetnode* rt, app_func_ptr_t f)
|
||||
{
|
||||
if ( rt ) {
|
||||
|
||||
f(rt -> v_element);
|
||||
|
||||
_apply( rt -> v_left, f );
|
||||
_apply( rt -> v_right, f );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void bset::del_elements(app_func_ptr_t func)
|
||||
{
|
||||
_del_elements(v_setroot, func);
|
||||
v_setroot = 0;
|
||||
}
|
||||
|
||||
void bset::_del_elements(bsetnode* rt, app_func_ptr_t func)
|
||||
{
|
||||
if ( rt ) {
|
||||
|
||||
bsetnode *lt = rt -> v_left;
|
||||
bsetnode *rg = rt -> v_right;
|
||||
|
||||
rt -> v_left = 0;
|
||||
rt -> v_right = 0;
|
||||
|
||||
func(rt -> v_element);
|
||||
delete rt;
|
||||
|
||||
_del_elements( lt, func );
|
||||
_del_elements( rg, func );
|
||||
}
|
||||
}
|
||||
|
||||
void bset::unlink_elements()
|
||||
{
|
||||
_unlink_elements(v_setroot);
|
||||
v_setroot = 0;
|
||||
}
|
||||
|
||||
void bset::_unlink_elements(bsetnode* rt)
|
||||
{
|
||||
if ( rt ) {
|
||||
|
||||
bsetnode *lt = rt -> v_left;
|
||||
bsetnode *rg = rt -> v_right;
|
||||
|
||||
rt -> v_left = 0;
|
||||
rt -> v_right = 0;
|
||||
delete rt;
|
||||
|
||||
_unlink_elements( lt );
|
||||
_unlink_elements( rg );
|
||||
}
|
||||
}
|
||||
|
||||
void bset::_smaller_member(const void* x, bsetnode* rt, void*& answer)
|
||||
{
|
||||
if ( rt == 0 ) return;
|
||||
|
||||
if ( (*f_cmp_func_eq)(x, rt -> v_element) == true ) {
|
||||
answer = rt -> v_element;
|
||||
return;
|
||||
}
|
||||
|
||||
if ( (*f_cmp_func_ls)(rt -> v_element, x) == true ) {
|
||||
answer = rt -> v_element;
|
||||
_smaller_member(x, rt -> v_right, answer);
|
||||
return;
|
||||
} else {
|
||||
_smaller_member(x, rt -> v_left, answer);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
if ( (*f_cmp_func_ls)(x, rt -> v_element) == true ) {
|
||||
if ( rt -> v_left )
|
||||
return _smaller_member(x, rt -> v_left);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ( (*f_cmp_func_eq)(x, rt -> v_element) == true ||
|
||||
rt -> v_right == 0
|
||||
)
|
||||
return rt -> v_element;
|
||||
|
||||
return _smaller_member(x, rt -> v_right);
|
||||
*/
|
||||
}
|
||||
|
||||
void* bset::_larger_member(const void* x, bsetnode* rt)
|
||||
{
|
||||
if ( gt(x, rt -> v_element) == true ) {
|
||||
if ( rt -> v_right )
|
||||
return _larger_member(x, rt -> v_right);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ( (*f_cmp_func_eq)(x, rt -> v_element) == true ||
|
||||
rt -> v_left == 0
|
||||
)
|
||||
return rt -> v_element;
|
||||
|
||||
return _larger_member(x, rt -> v_left);
|
||||
}
|
||||
|
||||
|
||||
void* bset::smaller_member(const void* x)
|
||||
{
|
||||
void* answer = 0;
|
||||
_smaller_member(x, v_setroot, answer);
|
||||
return answer;
|
||||
}
|
||||
|
||||
void* bset::larger_member(const void* x)
|
||||
{
|
||||
return _larger_member(x, v_setroot);
|
||||
}
|
||||
|
||||
Boolean bset::gt(const void* x, const void* y)
|
||||
{
|
||||
if ( (*f_cmp_func_eq)(x, y) == false &&
|
||||
(*f_cmp_func_ls)(x, y) == false
|
||||
)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
ostream& bset::asciiOut(ostream& out)
|
||||
{
|
||||
_asciiOut(out, v_setroot);
|
||||
return out;
|
||||
}
|
||||
|
||||
void bset::_asciiOut(ostream& out, bsetnode* rt)
|
||||
{
|
||||
if ( rt ) {
|
||||
out << long(rt -> v_element);
|
||||
out << "\n";
|
||||
_asciiOut( out, rt -> v_left );
|
||||
_asciiOut( out, rt -> v_right );
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef REGRESSION_TEST
|
||||
|
||||
#include <sys/time.h>
|
||||
#include "utility/pm_random.h"
|
||||
|
||||
int
|
||||
in_bset_test(bset& bst, int* ins, unsigned int& in_cts, int* outs, unsigned int& out_cts, pm_random& rand_gen)
|
||||
{
|
||||
if ( in_cts == 0 ) return 0;
|
||||
|
||||
int k = rand_gen.rand() % in_cts;
|
||||
|
||||
int_swap(ins[k], ins[in_cts-1]);
|
||||
|
||||
//cerr << "<-------------- removing " << ins[in_cts-1] << "\n";
|
||||
long j = (long)bst.remove((void*)ins[in_cts-1]);
|
||||
|
||||
if ( j != ins[in_cts-1] ) {
|
||||
cerr << "can't correctly remove " << ins[in_cts-1] << "\n";
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ( bst.member((void*)ins[in_cts-1]) != 0 ) {
|
||||
cerr << "element " << ins[in_cts-1] << " still in the set\n";
|
||||
return -1;
|
||||
}
|
||||
|
||||
outs[out_cts++] = ins[in_cts-1];
|
||||
in_cts--;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
out_bset_test(bset& bst, int* ins, unsigned int& in_cts, int* outs, unsigned int& out_cts,
|
||||
pm_random& rand_gen)
|
||||
{
|
||||
if ( out_cts == 0 ) return 0;
|
||||
|
||||
int k = rand_gen.rand() % out_cts;
|
||||
|
||||
int_swap(outs[k], outs[out_cts-1]);
|
||||
|
||||
if ( bst.member((void*)outs[out_cts-1]) != 0 ) {
|
||||
cerr << "can still find " << outs[out_cts-1] << "\n";
|
||||
return -1;
|
||||
}
|
||||
|
||||
//cerr << "--------------> inserting " << outs[out_cts-1] << "\n";
|
||||
|
||||
bst.insert((void*)outs[out_cts-1]);
|
||||
|
||||
if ( bst.member((void*)outs[out_cts-1]) == 0 ) {
|
||||
cerr << "can't find " << outs[out_cts-1] << "\n";
|
||||
return -1;
|
||||
}
|
||||
|
||||
ins[in_cts++] = outs[out_cts-1];
|
||||
out_cts--;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
bset_test(unsigned int in_cts, unsigned int out_cts, pm_random& rand_gen, unsigned int cycles)
|
||||
{
|
||||
int ok = 0;
|
||||
|
||||
int* ins = new int[in_cts+out_cts];
|
||||
int* outs = new int[in_cts+out_cts];
|
||||
|
||||
bset bst(void_eq, void_ls);
|
||||
|
||||
for ( int i=0; i<in_cts; i++ ) {
|
||||
ins[i] = i + 1;
|
||||
bst.insert((void*)ins[i]);
|
||||
}
|
||||
|
||||
for ( i=0; i<out_cts; i++ ) {
|
||||
outs[i] = i + in_cts + 1;
|
||||
}
|
||||
|
||||
for ( i=0; i<cycles; i++ ) {
|
||||
if ( rand_gen.rand_01() > 0.5 )
|
||||
ok |= in_bset_test(bst, ins, in_cts, outs, out_cts, rand_gen);
|
||||
else
|
||||
ok |= out_bset_test(bst, ins, in_cts, outs, out_cts, rand_gen);
|
||||
}
|
||||
|
||||
delete ins;
|
||||
delete outs;
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
#endif
|
||||
102
cde/programs/dtinfo/DtMmdb/dstr/bset.h
Normal file
102
cde/programs/dtinfo/DtMmdb/dstr/bset.h
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* $XConsortium: bset.h /main/4 1996/06/11 17:16:30 cde-hal $
|
||||
*
|
||||
* 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 _bset_h
|
||||
#define _bset_h 1
|
||||
|
||||
#include "dstr/set.h"
|
||||
//#include "storage/page_storage.h"
|
||||
|
||||
//**************************************************************
|
||||
//
|
||||
// a set implemented based on binary search tree data structure.
|
||||
//
|
||||
//**************************************************************
|
||||
|
||||
Boolean void_ls(const void* o1, const void* o2);
|
||||
Boolean void_eq(const void* o1, const void* o2);
|
||||
|
||||
class bset;
|
||||
|
||||
struct bsetnode
|
||||
{
|
||||
void* v_element;
|
||||
bsetnode* v_left;
|
||||
bsetnode* v_right;
|
||||
|
||||
bsetnode(void* x) : v_element(x), v_left(0), v_right(0)
|
||||
{};
|
||||
virtual ~bsetnode() { delete v_left; delete v_right; };
|
||||
};
|
||||
|
||||
class bset : public set {
|
||||
|
||||
public:
|
||||
bset(cmp_func_ptr_t eq = void_eq, cmp_func_ptr_t ls = void_ls);
|
||||
virtual ~bset();
|
||||
|
||||
virtual Boolean insert(void* element); // return false if element
|
||||
// is already there
|
||||
virtual void* remove(void* element);
|
||||
virtual void* member(const void* element);
|
||||
|
||||
virtual void* smaller_member(const void* element);
|
||||
virtual void* larger_member(const void* element);
|
||||
|
||||
// print elements as int.
|
||||
virtual ostream& asciiOut(ostream&);
|
||||
|
||||
virtual void unlink_elements(); // unlink those v_elments
|
||||
virtual void del_elements(app_func_ptr_t func);
|
||||
virtual void apply(app_func_ptr_t);
|
||||
|
||||
protected:
|
||||
|
||||
virtual void* _member(const void* element, bsetnode* rt);
|
||||
virtual Boolean _insert(void* element, bsetnode* rt);
|
||||
virtual void* _move(bsetnode* target, bsetnode* source);
|
||||
virtual void* _remove_min(void* element, bsetnode*& rt);
|
||||
virtual void*_remove(void* element, bsetnode*& rt);
|
||||
virtual void _del_elements(bsetnode* rt, app_func_ptr_t func);
|
||||
virtual void _apply(bsetnode* rt, app_func_ptr_t f);
|
||||
virtual void _unlink_elements(bsetnode* rt);
|
||||
|
||||
virtual void _smaller_member(const void* element, bsetnode* rt, void*& answer);
|
||||
virtual void* _larger_member(const void* element, bsetnode* rt);
|
||||
Boolean gt(const void* x, const void* y);
|
||||
|
||||
virtual void _asciiOut(ostream&, bsetnode* rt);
|
||||
|
||||
protected:
|
||||
bsetnode* v_setroot;
|
||||
|
||||
};
|
||||
|
||||
typedef bset* bsetPtr;
|
||||
|
||||
#endif
|
||||
209
cde/programs/dtinfo/DtMmdb/dstr/dlist.C
Normal file
209
cde/programs/dtinfo/DtMmdb/dstr/dlist.C
Normal file
@@ -0,0 +1,209 @@
|
||||
/*
|
||||
* $XConsortium: dlist.C /main/5 1996/08/21 15:51:48 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
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "dstr/dlist.h"
|
||||
|
||||
#ifdef C_API
|
||||
#include "utility/c_stream.h"
|
||||
#else
|
||||
#include <stream.h>
|
||||
#endif
|
||||
|
||||
|
||||
dlist::dlist(Boolean x) :
|
||||
v_ct(0), v_head(0), v_tail(0), remove_cells_when_done(x)
|
||||
{
|
||||
}
|
||||
|
||||
dlist::~dlist()
|
||||
{
|
||||
if ( remove_cells_when_done == true )
|
||||
remove();
|
||||
}
|
||||
|
||||
void dlist::remove()
|
||||
{
|
||||
long ind = first();
|
||||
while ( ind ) {
|
||||
dlist_cell *p = (dlist_cell*)ind;
|
||||
next(ind);
|
||||
delete p;
|
||||
}
|
||||
}
|
||||
|
||||
void dlist::append(dlist* tail_list)
|
||||
{
|
||||
if ( tail_list == 0 ) return;
|
||||
|
||||
if ( v_tail != 0 )
|
||||
v_tail -> v_succ = tail_list -> v_head;
|
||||
|
||||
if ( tail_list -> v_head )
|
||||
tail_list -> v_head -> v_pred = v_tail;
|
||||
|
||||
if ( v_head == 0 )
|
||||
v_head = tail_list -> v_head;
|
||||
|
||||
v_tail = tail_list -> v_tail;
|
||||
v_ct += tail_list -> v_ct;
|
||||
|
||||
tail_list -> v_head = tail_list -> v_tail = 0;
|
||||
tail_list -> v_ct = 0;
|
||||
}
|
||||
|
||||
void dlist::insert_before(dlist_cell* ref, dlist_cell* x)
|
||||
{
|
||||
/*
|
||||
debug(cerr, "insert before");
|
||||
debug(cerr, int(x));
|
||||
debug(cerr, int(head));
|
||||
debug(cerr, int(tail));
|
||||
*/
|
||||
if ( v_head == 0 ) {
|
||||
x -> v_pred = x -> v_succ = 0;
|
||||
v_head = v_tail = x;
|
||||
} else
|
||||
if ( ref == v_head ) {
|
||||
x -> v_succ = v_head ;
|
||||
x -> v_pred = 0;
|
||||
v_head = x;
|
||||
ref -> v_pred = x;
|
||||
} else {
|
||||
ref -> v_pred -> v_succ = x;
|
||||
x -> v_pred = ref -> v_pred;
|
||||
x -> v_succ = ref;
|
||||
ref -> v_pred = x;
|
||||
}
|
||||
v_ct++;
|
||||
/*
|
||||
debug(cerr, "insert before done");
|
||||
debug(cerr, int(head));
|
||||
debug(cerr, int(tail));
|
||||
*/
|
||||
}
|
||||
|
||||
void dlist::insert_after(dlist_cell* ref, dlist_cell* x)
|
||||
{
|
||||
if ( v_head == 0 ) {
|
||||
x -> v_pred = x -> v_succ = 0;
|
||||
v_head = v_tail = x;
|
||||
} else
|
||||
if ( ref == v_tail ) {
|
||||
ref -> v_succ = x;
|
||||
x -> v_succ = 0;
|
||||
v_tail = x;
|
||||
x -> v_pred = ref;
|
||||
} else {
|
||||
ref -> v_succ -> v_pred = x;
|
||||
x -> v_succ = ref -> v_succ;
|
||||
x -> v_pred = ref;
|
||||
ref -> v_succ = x;
|
||||
}
|
||||
v_ct++;
|
||||
}
|
||||
|
||||
void dlist::insert_as_head(dlist_cell* x)
|
||||
{
|
||||
if ( v_head == 0 ) {
|
||||
x -> v_pred = x -> v_succ = 0;
|
||||
v_head = v_tail = x;
|
||||
} else {
|
||||
v_head -> v_pred = x;
|
||||
x -> v_pred = 0;
|
||||
x -> v_succ = v_head;
|
||||
v_head = x;
|
||||
}
|
||||
v_ct++;
|
||||
}
|
||||
|
||||
void dlist::insert_as_tail(dlist_cell* x)
|
||||
{
|
||||
if ( v_head == 0 ) {
|
||||
x -> v_pred = x -> v_succ = 0;
|
||||
v_head = v_tail = x;
|
||||
} else {
|
||||
v_tail -> v_succ = x;
|
||||
x -> v_succ = 0;
|
||||
x -> v_pred = v_tail;
|
||||
v_tail = x;
|
||||
}
|
||||
v_ct++;
|
||||
}
|
||||
|
||||
void dlist::delete_cell(dlist_cell* x)
|
||||
{
|
||||
/*
|
||||
MESSAGE(cerr, "delete_cell()");
|
||||
debug(cerr, int(x));
|
||||
debug(cerr, int(head));
|
||||
debug(cerr, int(tail));
|
||||
debug(cerr, ct);
|
||||
*/
|
||||
|
||||
if ( x == 0 )
|
||||
return ;
|
||||
|
||||
if ( x == v_head ) {
|
||||
if ( v_ct == 1 )
|
||||
v_head = v_tail = 0;
|
||||
else {
|
||||
v_head = v_head -> v_succ;
|
||||
v_head -> v_pred = 0;
|
||||
}
|
||||
} else
|
||||
if ( x == v_tail ) {
|
||||
v_tail = v_tail -> v_pred;
|
||||
v_tail -> v_succ = 0;
|
||||
} else {
|
||||
x -> v_pred -> v_succ = x -> v_succ ;
|
||||
x -> v_succ -> v_pred = x -> v_pred ;
|
||||
}
|
||||
|
||||
v_ct--;
|
||||
|
||||
x -> v_succ = x -> v_pred = 0;
|
||||
}
|
||||
|
||||
long dlist::first()
|
||||
{
|
||||
return long(v_head);
|
||||
}
|
||||
|
||||
long dlist::last()
|
||||
{
|
||||
return long (v_tail);
|
||||
}
|
||||
|
||||
void dlist::next(long& index)
|
||||
{
|
||||
if ( index == long(v_tail) )
|
||||
index = 0;
|
||||
else
|
||||
index = long( ((dlist_cell*)(index)) -> v_succ );
|
||||
}
|
||||
|
||||
74
cde/programs/dtinfo/DtMmdb/dstr/dlist.h
Normal file
74
cde/programs/dtinfo/DtMmdb/dstr/dlist.h
Normal file
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* $XConsortium: dlist.h /main/4 1996/07/18 14:29:10 drk $
|
||||
*
|
||||
* Copyright (c) 1992 HaL Computer Systems, Inc. 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, Inc. Use, disclosure, or reproduction is prohibited
|
||||
* without the prior express written permission of HaL Computer Systems, Inc.
|
||||
*
|
||||
* RESTRICTED RIGHTS LEGEND
|
||||
* Use, duplication, or disclosure by the Government is subject to
|
||||
* 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, Inc.
|
||||
* 1315 Dell Avenue, Campbell, CA 95008
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef _dlist_h
|
||||
#define _dlist_h 1
|
||||
|
||||
#include "utility/debug.h"
|
||||
#include "utility/types.h"
|
||||
#include "dstr/dlist_cell.h"
|
||||
|
||||
// doubly-linked list class
|
||||
|
||||
class dlist {
|
||||
|
||||
public:
|
||||
dlist(Boolean remove_cells = true);
|
||||
virtual ~dlist();
|
||||
|
||||
// append a dlist. x becomes part of this list. no copy
|
||||
// is performed. tail_list -> head and tail_list -> tail
|
||||
// are set to NULL. Also, tail_list -> ct = 0.
|
||||
void append(dlist* tail_list);
|
||||
|
||||
// update functions
|
||||
void insert_before(dlist_cell* ref, dlist_cell* x) ; //insert before ref
|
||||
void insert_after(dlist_cell* ref, dlist_cell* x) ; // insert after ref
|
||||
void insert_as_head(dlist_cell* x); // insert x at head
|
||||
void insert_as_tail(dlist_cell* x); // insert x at tail
|
||||
|
||||
void delete_cell(dlist_cell*) ;
|
||||
void remove() ; // remove all cells (call delete on each cell)
|
||||
|
||||
// empty the list without free cells
|
||||
void empty_list() { v_head = v_tail = 0; v_ct = 0;} ;
|
||||
|
||||
// status function
|
||||
int count() { return v_ct; }; // number of cells in the list
|
||||
dlist_cell* get_head() { return v_head; };
|
||||
dlist_cell* get_tail() { return v_tail; };
|
||||
|
||||
long first(); // 0 if the list is empty
|
||||
void next(long& index);
|
||||
long last(); // 0 if the list is empty
|
||||
|
||||
protected:
|
||||
dlist_cell *v_head; // head pointer
|
||||
dlist_cell *v_tail; // tail pointer
|
||||
int v_ct; // cell in the list
|
||||
int remove_cells_when_done;
|
||||
};
|
||||
|
||||
typedef dlist *dlistPtr;
|
||||
|
||||
#endif
|
||||
12
cde/programs/dtinfo/DtMmdb/dstr/dlist_cell.C
Normal file
12
cde/programs/dtinfo/DtMmdb/dstr/dlist_cell.C
Normal file
@@ -0,0 +1,12 @@
|
||||
// $XConsortium: dlist_cell.cc /main/3 1996/06/11 17:16:50 cde-hal $
|
||||
|
||||
#include "dstr/dlist_cell.h"
|
||||
|
||||
dlist_cell::dlist_cell() : v_pred(0), v_succ(0)
|
||||
{
|
||||
}
|
||||
|
||||
dlist_cell::~dlist_cell()
|
||||
{
|
||||
}
|
||||
|
||||
43
cde/programs/dtinfo/DtMmdb/dstr/dlist_cell.h
Normal file
43
cde/programs/dtinfo/DtMmdb/dstr/dlist_cell.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* $XConsortium: dlist_cell.h /main/3 1996/06/11 17:16:55 cde-hal $
|
||||
*
|
||||
* Copyright (c) 1992 HaL Computer Systems, Inc. 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, Inc. Use, disclosure, or reproduction is prohibited
|
||||
* without the prior express written permission of HaL Computer Systems, Inc.
|
||||
*
|
||||
* RESTRICTED RIGHTS LEGEND
|
||||
* Use, duplication, or disclosure by the Government is subject to
|
||||
* 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, Inc.
|
||||
* 1315 Dell Avenue, Campbell, CA 95008
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _dlist_cell_h
|
||||
#define _dlist_cell_h 1
|
||||
|
||||
#include "utility/debug.h"
|
||||
|
||||
// doubly-linked list cell class
|
||||
|
||||
class dlist_cell {
|
||||
|
||||
public:
|
||||
dlist_cell() ;
|
||||
virtual ~dlist_cell() ;
|
||||
|
||||
dlist_cell *v_pred ; // prec pointer
|
||||
dlist_cell *v_succ ; // succ pointer
|
||||
|
||||
};
|
||||
|
||||
typedef dlist_cell *dlist_cellPtr;
|
||||
|
||||
#endif
|
||||
26
cde/programs/dtinfo/DtMmdb/dstr/dlist_void_ptr_cell.h
Normal file
26
cde/programs/dtinfo/DtMmdb/dstr/dlist_void_ptr_cell.h
Normal file
@@ -0,0 +1,26 @@
|
||||
/* $XConsortium: dlist_void_ptr_cell.h /main/3 1996/06/11 17:17:00 cde-hal $ */
|
||||
|
||||
|
||||
#ifndef _dlist_void_ptr_cell_h
|
||||
#define _dlist_void_ptr_cell_h 1
|
||||
|
||||
#include "utility/types.h"
|
||||
#include "dstr/dlist_cell.h"
|
||||
|
||||
// doubly-linked list cell class, voidPtr as data ptr.
|
||||
|
||||
class dlist_void_ptr_cell : public dlist_cell {
|
||||
|
||||
public:
|
||||
dlist_void_ptr_cell(voidPtr vp) : data(vp) {};
|
||||
virtual ~dlist_void_ptr_cell() {};
|
||||
|
||||
voidPtr void_ptr() { return data; };
|
||||
|
||||
protected:
|
||||
voidPtr data;
|
||||
};
|
||||
|
||||
typedef dlist_void_ptr_cell *dlist_void_ptr_cellPtr;
|
||||
|
||||
#endif
|
||||
55
cde/programs/dtinfo/DtMmdb/dstr/dstr_test.C
Normal file
55
cde/programs/dtinfo/DtMmdb/dstr/dstr_test.C
Normal file
@@ -0,0 +1,55 @@
|
||||
/* $XConsortium: dstr_test.C /main/6 1996/08/21 15:56:38 drk $ */
|
||||
|
||||
#include "dstr/dstr_test.h"
|
||||
#include "utility/pm_random.h"
|
||||
#include "utility/funcs.h"
|
||||
|
||||
#if defined(__uxp__)
|
||||
#include <sys/times.h>
|
||||
#elif __osf__
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#ifdef REGRESSION_TEST
|
||||
|
||||
extern
|
||||
int
|
||||
bset_test(unsigned int in_cts, unsigned int out_cts,
|
||||
pm_random& rand_gen, unsigned int cycles);
|
||||
|
||||
int dstr_test(int argc, char** argv)
|
||||
{
|
||||
if ( strcmp(argv[1], "bset_test") == 0 ) {
|
||||
if ( argc != 5 ) {
|
||||
cerr << "usage: bset_test in_count out_count num_cycles \n";
|
||||
cerr << " where: \n";
|
||||
cerr << " in_count: number of elements originally in the set\n";
|
||||
cerr << " out_count: number of elements originally not in the set\n";
|
||||
cerr << " num_cycles: number of tests\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
int in_cts = atoi(argv[2]);
|
||||
int out_cts = atoi(argv[3]);
|
||||
int cycles = atoi(argv[4]);
|
||||
|
||||
#ifdef __uxp__
|
||||
int seed;
|
||||
struct tms tp;
|
||||
if ((seed = (int)times(&tp)) < 0)
|
||||
seed = 19;
|
||||
#else
|
||||
struct timeval tp;
|
||||
struct timezone tzp;
|
||||
|
||||
int seed = ( gettimeofday(&tp, &tzp) == 0 ) ? int(tp.tv_sec) : 19;
|
||||
#endif
|
||||
pm_random rand_gen;
|
||||
rand_gen.seed(seed);
|
||||
|
||||
return bset_test(in_cts, out_cts, rand_gen, cycles);
|
||||
} else
|
||||
return 2;
|
||||
}
|
||||
|
||||
#endif
|
||||
10
cde/programs/dtinfo/DtMmdb/dstr/dstr_test.h
Normal file
10
cde/programs/dtinfo/DtMmdb/dstr/dstr_test.h
Normal file
@@ -0,0 +1,10 @@
|
||||
/* $XConsortium: dstr_test.h /main/4 1996/07/18 16:32:31 drk $ */
|
||||
|
||||
#ifndef _dstr_test_h
|
||||
#define _dstr_test_h
|
||||
|
||||
#ifdef REGRESSION_TEST
|
||||
int dstr_test(int argc, char** argv);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
203
cde/programs/dtinfo/DtMmdb/dstr/heap.C
Normal file
203
cde/programs/dtinfo/DtMmdb/dstr/heap.C
Normal file
@@ -0,0 +1,203 @@
|
||||
/*
|
||||
* $XConsortium: heap.cc /main/4 1996/07/18 14:29:27 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
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "dstr/heap.h"
|
||||
|
||||
heap::heap(cmp_func_ptr_t eq, cmp_func_ptr_t ls, int max) :
|
||||
buffer(MAX(1, max)*sizeof(voidPtr)), f_cmp_func_eq(eq), f_cmp_func_ls(ls)
|
||||
{
|
||||
// the 0th element is never used.
|
||||
char z[16];
|
||||
|
||||
memset(z, 0, 16);
|
||||
|
||||
buffer::put(z, sizeof(voidPtr));
|
||||
v_updated = false;
|
||||
}
|
||||
|
||||
heap::~heap()
|
||||
{
|
||||
/*
|
||||
voidPtr *heap_space = (voidPtr*)buffer::get_base();
|
||||
|
||||
int ct = count();
|
||||
|
||||
for ( int i=1; i<=ct; i++ )
|
||||
delete heap_space[i];
|
||||
*/
|
||||
}
|
||||
|
||||
/*
|
||||
int heap::count()
|
||||
{
|
||||
// the 0th element is excluded
|
||||
return buffer::content_sz() / sizeof(voidPtr) - 1;
|
||||
}
|
||||
*/
|
||||
|
||||
Boolean heap::insert(voidPtr elm)
|
||||
{
|
||||
if ( buf_sz() < content_sz() + 2*sizeof(voidPtr) )
|
||||
buffer::expand_chunk(2*buf_sz()) ;
|
||||
|
||||
long x = long(elm);
|
||||
buffer::put(x);
|
||||
|
||||
v_updated = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Boolean heap::insert_heapify(voidPtr elm)
|
||||
{
|
||||
insert(elm);
|
||||
|
||||
int j = count(); int i = j/2;
|
||||
|
||||
voidPtr *heap_space = (voidPtr*)buffer::get_base();
|
||||
|
||||
while ( i > 0 && (*f_cmp_func_ls)(heap_space[i], elm) == true ) {
|
||||
heap_space[j] = heap_space[i];
|
||||
j = i; i /= 2;
|
||||
}
|
||||
heap_space[j] = elm;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void heap::adjust(int i, call_back_func_ptr_t call_back)
|
||||
{
|
||||
voidPtr *heap_space = (voidPtr*)buffer::get_base();
|
||||
|
||||
int j = 2*i;
|
||||
voidPtr item = heap_space[i];
|
||||
|
||||
while ( j <= count() ) {
|
||||
if ( j < count() &&
|
||||
(*f_cmp_func_ls)(heap_space[j], heap_space[j+1]) == true
|
||||
) {
|
||||
j++;
|
||||
}
|
||||
if ( (*f_cmp_func_ls)(item, heap_space[j]) == false )
|
||||
break;
|
||||
else {
|
||||
heap_space[j/2] = heap_space[j];
|
||||
if ( call_back != 0 )
|
||||
(*call_back)(j/2, heap_space[j/2]);
|
||||
}
|
||||
|
||||
j *= 2;
|
||||
}
|
||||
|
||||
heap_space[j/2] = item;
|
||||
|
||||
if ( call_back != 0 )
|
||||
(*call_back)(j/2, item);
|
||||
}
|
||||
|
||||
voidPtr heap::max_elm()
|
||||
{
|
||||
voidPtr *heap_space = (voidPtr*)buffer::get_base();
|
||||
|
||||
if ( count() > 0 )
|
||||
return heap_space[1];
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
void heap::adjust_max_to(voidPtr new_max_item)
|
||||
{
|
||||
voidPtr *heap_space = (voidPtr*)buffer::get_base();
|
||||
|
||||
heap_space[1] = new_max_item;
|
||||
adjust(1);
|
||||
v_updated = true;
|
||||
}
|
||||
|
||||
void heap::heapify()
|
||||
{
|
||||
//for ( int i = (int)floor(double(count())/2); i>=1; adjust(i--) );
|
||||
|
||||
for ( int i = count()/2; i>=1; adjust(i--) );
|
||||
}
|
||||
|
||||
void heap::remove()
|
||||
{
|
||||
set_content_sz(0);
|
||||
buffer::put((unsigned int)0);
|
||||
v_updated = false;
|
||||
}
|
||||
|
||||
void heap::delete_max(call_back_func_ptr_t call_back)
|
||||
{
|
||||
//MESSAGE(cerr, "delete max");
|
||||
voidPtr *heap_space = (voidPtr*)buffer::get_base();
|
||||
|
||||
int ct = count();
|
||||
|
||||
heap_space[1] = heap_space[ct];
|
||||
set_content_sz(content_sz() - sizeof(voidPtr));
|
||||
|
||||
ct--;
|
||||
|
||||
adjust(1, call_back);
|
||||
}
|
||||
|
||||
void heap::_delete_max(int i, voidPtr* heap_array)
|
||||
{
|
||||
int target = ( heap_array[i+1] == 0 ) ? 2*i : 2*i+1;
|
||||
|
||||
voidPtr tmp = heap_array[i];
|
||||
heap_array[i] = heap_array[target] ;
|
||||
heap_array[target] = tmp;
|
||||
|
||||
if ( heap_array[target] != 0 )
|
||||
_delete_max(target, heap_array);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int heap::first()
|
||||
{
|
||||
return ( count() >= 1 ) ? 1 : 0;
|
||||
}
|
||||
|
||||
void heap::next(int& ind)
|
||||
{
|
||||
ind = ( ind < count() ) ? (ind+1) : 0;
|
||||
}
|
||||
|
||||
voidPtr heap::operator()(int ind)
|
||||
{
|
||||
if ( INRANGE(ind, 1, count()) ) {
|
||||
voidPtr *heap_space = (voidPtr*)buffer::get_base();
|
||||
return heap_space[ind];
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
|
||||
78
cde/programs/dtinfo/DtMmdb/dstr/heap.h
Normal file
78
cde/programs/dtinfo/DtMmdb/dstr/heap.h
Normal file
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* $XConsortium: heap.h /main/3 1996/06/11 17:17:11 cde-hal $
|
||||
*
|
||||
* Copyright (c) 1992 HaL Computer Systems, Inc. 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, Inc. Use, disclosure, or reproduction is prohibited
|
||||
* without the prior express written permission of HaL Computer Systems, Inc.
|
||||
*
|
||||
* RESTRICTED RIGHTS LEGEND
|
||||
* Use, duplication, or disclosure by the Government is subject to
|
||||
* 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, Inc.
|
||||
* 1315 Dell Avenue, Campbell, CA 95008
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _heap_h
|
||||
#define _heap_h 1
|
||||
|
||||
#include "utility/funcs.h"
|
||||
#include "utility/buffer.h"
|
||||
|
||||
typedef void (*call_back_func_ptr_t)(int, void*);
|
||||
|
||||
class heap : private buffer {
|
||||
|
||||
|
||||
public:
|
||||
heap(cmp_func_ptr_t eq, cmp_func_ptr_t ls, int exp_elements = 1000);
|
||||
virtual ~heap();
|
||||
|
||||
// insert function, no heapifying action taken
|
||||
Boolean insert(voidPtr elm) ;
|
||||
Boolean insert_heapify(voidPtr elm) ;
|
||||
|
||||
// make a heap out of inserted elements
|
||||
void heapify();
|
||||
|
||||
// retrieve function
|
||||
void* max_elm() ;
|
||||
void adjust_max_to(voidPtr new_max_item);
|
||||
|
||||
void delete_max(call_back_func_ptr_t call_back_func_t = 0);
|
||||
void remove(); // remove all elements
|
||||
|
||||
// status function: number of elements in the heap
|
||||
int count() {
|
||||
return buffer::content_sz() / sizeof(voidPtr) - 1;
|
||||
};
|
||||
|
||||
Boolean update() { return v_updated; };
|
||||
void adjust(int i, call_back_func_ptr_t call_back_func_t = 0);
|
||||
|
||||
// iterator
|
||||
int first();
|
||||
voidPtr operator()(int ind);
|
||||
void next(int& ind);
|
||||
|
||||
protected:
|
||||
void _delete_max(int i, voidPtr *heap_space);
|
||||
|
||||
protected:
|
||||
Boolean v_updated;
|
||||
|
||||
cmp_func_ptr_t f_cmp_func_eq;
|
||||
cmp_func_ptr_t f_cmp_func_ls;
|
||||
};
|
||||
|
||||
typedef heap *heapPtr;
|
||||
|
||||
#endif
|
||||
|
||||
37
cde/programs/dtinfo/DtMmdb/dstr/index_agent.C
Normal file
37
cde/programs/dtinfo/DtMmdb/dstr/index_agent.C
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* $XConsortium: index_agent.cc /main/3 1996/06/11 17:17:16 cde-hal $
|
||||
*
|
||||
* 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 "dstr/index_agent.h"
|
||||
|
||||
index_agent::index_agent(): n(0)
|
||||
{
|
||||
}
|
||||
|
||||
index_agent::~index_agent()
|
||||
{
|
||||
}
|
||||
62
cde/programs/dtinfo/DtMmdb/dstr/index_agent.h
Normal file
62
cde/programs/dtinfo/DtMmdb/dstr/index_agent.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* $XConsortium: index_agent.h /main/3 1996/06/11 17:17:20 cde-hal $
|
||||
*
|
||||
* 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 _index_agent_h
|
||||
#define _index_agent_h 1
|
||||
|
||||
#include "utility/funcs.h"
|
||||
#include "utility/ostring.h"
|
||||
#include "dynhash/data_t.h"
|
||||
|
||||
//**************************************************************
|
||||
// A abstract index_agent class
|
||||
//**************************************************************
|
||||
|
||||
class index_agent {
|
||||
|
||||
public:
|
||||
index_agent() ;
|
||||
virtual ~index_agent() ;
|
||||
|
||||
virtual Boolean insert(data_t& v) = 0; // insert a key
|
||||
virtual Boolean remove(data_t& v) = 0; // remove a key
|
||||
virtual Boolean member(data_t& v) = 0; // member test
|
||||
virtual void clean() = 0; // remove all keys
|
||||
|
||||
virtual int no_keys() const { return n; }; // return key set size
|
||||
|
||||
virtual ostream& asciiOut(ostream& out) = 0;
|
||||
virtual istream& asciiIn(istream& in) = 0;
|
||||
|
||||
protected:
|
||||
unsigned int n; // current key set size
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
257
cde/programs/dtinfo/DtMmdb/dstr/memory_pool.C
Normal file
257
cde/programs/dtinfo/DtMmdb/dstr/memory_pool.C
Normal file
@@ -0,0 +1,257 @@
|
||||
/*
|
||||
* $XConsortium: memory_pool.cc /main/4 1996/07/18 14:29:52 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
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "dstr/memory_pool.h"
|
||||
|
||||
#define NUM_CHUNKS 50
|
||||
|
||||
#ifdef C_API
|
||||
memory_pool* g_memory_pool_ptr = 0;
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
///////////////////////////////////////////////////
|
||||
|
||||
int g_carrier = 0;
|
||||
|
||||
chunk_carrier::chunk_carrier(int chk_sz, int chks ) :
|
||||
chunk_sz(ll4(chk_sz)), max_chunks(chks)
|
||||
{
|
||||
/*
|
||||
debug(cerr, chunk_sz);
|
||||
debug(cerr, max_chunks);
|
||||
debug(cerr, int(this));
|
||||
*/
|
||||
|
||||
alloc_sz = max_chunks * (chunk_sz + sizeof(chunk_manage_record_t));
|
||||
g_carrier += alloc_sz;
|
||||
carrier_ptr = new char[alloc_sz];
|
||||
}
|
||||
|
||||
chunk_carrier::~chunk_carrier()
|
||||
{
|
||||
delete carrier_ptr;
|
||||
}
|
||||
|
||||
dlist* chunk_carrier::init_ptrs()
|
||||
{
|
||||
dlist* w = new dlist;
|
||||
|
||||
int offset = 0;
|
||||
for ( int i=0; i<max_chunks; i++ ) {
|
||||
|
||||
chunk_manage_record_t* x =
|
||||
(chunk_manage_record_t*)(carrier_ptr + offset);
|
||||
|
||||
x -> chunk_carrier_ptr = this;
|
||||
|
||||
w -> insert_as_tail(x);
|
||||
|
||||
offset += (chunk_sz + sizeof(chunk_manage_record_t));
|
||||
}
|
||||
|
||||
return w;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
///////////////////////////////////////////////////
|
||||
|
||||
fix_chunk_pool::fix_chunk_pool(int x) : chunk_sz(x), chunks(1)
|
||||
{
|
||||
init_one_chunk_carrier();
|
||||
}
|
||||
|
||||
void fix_chunk_pool::init_one_chunk_carrier()
|
||||
{
|
||||
chunk_carrier* x = new chunk_carrier(chunk_sz, NUM_CHUNKS);
|
||||
|
||||
chunk_carrier_list.insert_as_tail(new dlist_void_ptr_cell(x));
|
||||
|
||||
dlist* z = x -> init_ptrs() ;
|
||||
|
||||
free_chunk_list.append( z );
|
||||
|
||||
delete z;
|
||||
}
|
||||
|
||||
fix_chunk_pool::~fix_chunk_pool()
|
||||
{
|
||||
free_chunk_list.empty_list();
|
||||
|
||||
long x = chunk_carrier_list.first();
|
||||
|
||||
while ( x ) {
|
||||
chunk_carrier *y = (chunk_carrier*)
|
||||
(((dlist_void_ptr_cell*)x) -> void_ptr());
|
||||
delete y;
|
||||
chunk_carrier_list.next(x);
|
||||
}
|
||||
|
||||
//debug(cerr, chunk_sz);
|
||||
//debug(cerr, chunks);
|
||||
}
|
||||
|
||||
char* fix_chunk_pool::alloc()
|
||||
{
|
||||
if ( free_chunk_list.count() == 0 ) {
|
||||
//chunks++;
|
||||
init_one_chunk_carrier();
|
||||
}
|
||||
|
||||
chunk_manage_record_t *x =
|
||||
(chunk_manage_record_t*)free_chunk_list.get_head();
|
||||
|
||||
free_chunk_list.delete_cell(x);
|
||||
|
||||
return (char*)( ((char*)x) + sizeof(chunk_manage_record_t) );
|
||||
}
|
||||
|
||||
void fix_chunk_pool::free(char* x)
|
||||
{
|
||||
/*
|
||||
chunk_manage_record_t* chk_mng_ptr =
|
||||
(chunk_manage_record_t*)
|
||||
(x - sizeof(chunk_manage_record_t));
|
||||
*/
|
||||
|
||||
free_chunk_list.insert_as_tail(
|
||||
(chunk_manage_record_t*)
|
||||
(x - sizeof(chunk_manage_record_t))
|
||||
);
|
||||
|
||||
|
||||
// chunk_carrier* z = chk_mng_ptr -> chunk_carrier_ptr;
|
||||
//
|
||||
//
|
||||
// int delta = x - z -> carrier_ptr;
|
||||
//
|
||||
// if ( INRANGE(delta, 0, z -> alloc_sz) )
|
||||
///*
|
||||
// if ( ((char*)chk_mng_ptr - z -> carrier_ptr) %
|
||||
// (z -> chunk_sz + sizeof(chunk_manage_record_t))
|
||||
// ==
|
||||
// 0
|
||||
// )
|
||||
//*/
|
||||
// free_chunk_list.insert_as_tail(chk_mng_ptr);
|
||||
// else {
|
||||
// MESSAGE(cerr, "fix_chunk_pool::free(): bad ptr");
|
||||
// debug(cerr, int(x));
|
||||
///*
|
||||
// debug(cerr, int((char*)chk_mng_ptr - z -> carrier_ptr));
|
||||
// debug(cerr, z ->chunk_sz + sizeof(chunk_manage_record_t));
|
||||
//*/
|
||||
// debug(cerr, delta);
|
||||
// debug(cerr, int(z -> carrier_ptr));
|
||||
// abort();
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
///////////////////////////////////////////////////
|
||||
|
||||
memory_pool::memory_pool(int x) :
|
||||
max_alloc_size_from_pool(x), vm_pool_vector(MAX_CHUNK_SZ)
|
||||
{
|
||||
//MESSAGE(cerr, "memory_pool cstr");
|
||||
//debug(cerr, int(this));
|
||||
}
|
||||
|
||||
int g_memory_size = 0;
|
||||
|
||||
memory_pool::~memory_pool()
|
||||
{
|
||||
for ( int i=4; i<MAX_CHUNK_SZ; i++ ) {
|
||||
delete (fix_chunk_pool*)vm_pool_vector[i];
|
||||
}
|
||||
//cerr << "g_memory_size = " << g_memory_size << "\n";
|
||||
//cerr << "g_carrier= " << g_carrier << "\n";
|
||||
}
|
||||
|
||||
|
||||
char* memory_pool::alloc(size_t sz)
|
||||
{
|
||||
/*
|
||||
MESSAGE(cerr, "=======");
|
||||
debug(cerr, int(this));
|
||||
debug(cerr, sz);
|
||||
*/
|
||||
|
||||
//g_memory_size += sz;
|
||||
|
||||
if ( INRANGE(sz, 4, MAX_CHUNK_SZ) ) {
|
||||
|
||||
fix_chunk_pool *x =
|
||||
(fix_chunk_pool*)vm_pool_vector[sz];
|
||||
|
||||
if ( x == 0 ) {
|
||||
//MESSAGE(cerr, "calling new fix_chunk_pool");
|
||||
x = new fix_chunk_pool(sz);
|
||||
vm_pool_vector.insert(x, sz);
|
||||
}
|
||||
|
||||
return x -> alloc();
|
||||
|
||||
} else {
|
||||
return new char[sz];
|
||||
}
|
||||
//MESSAGE(cerr, "=======");
|
||||
}
|
||||
|
||||
void memory_pool::free(char* str)
|
||||
{
|
||||
int sz = ((chunk_manage_record_t*)
|
||||
(str - sizeof(chunk_manage_record_t))) ->
|
||||
chunk_carrier_ptr -> chunk_sz;
|
||||
|
||||
if ( INRANGE(sz, 4, MAX_CHUNK_SZ) ) {
|
||||
|
||||
fix_chunk_pool* x = (fix_chunk_pool*)vm_pool_vector[sz];
|
||||
|
||||
if ( x == 0 ) {
|
||||
debug(cerr, sz);
|
||||
throw(stringException(
|
||||
"memory_pool::free(): fix_chunk_pool missing"
|
||||
)
|
||||
);
|
||||
} else
|
||||
x -> free(str);
|
||||
|
||||
} else {
|
||||
delete str;
|
||||
}
|
||||
}
|
||||
|
||||
124
cde/programs/dtinfo/DtMmdb/dstr/memory_pool.h
Normal file
124
cde/programs/dtinfo/DtMmdb/dstr/memory_pool.h
Normal file
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* $XConsortium: memory_pool.h /main/3 1996/06/11 17:17:31 cde-hal $
|
||||
*
|
||||
* 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 _memory_pool
|
||||
#define _memory_pool 1
|
||||
|
||||
#include "utility/funcs.h"
|
||||
#include "dstr/dlist_void_ptr_cell.h"
|
||||
#include "dstr/dlist.h"
|
||||
#include "dstr/void_ptr_array.h"
|
||||
|
||||
#define MAX_CHUNK_SZ 128
|
||||
|
||||
class chunk_carrier;
|
||||
|
||||
class chunk_manage_record_t : public dlist_cell
|
||||
{
|
||||
|
||||
public:
|
||||
chunk_carrier* chunk_carrier_ptr;
|
||||
|
||||
chunk_manage_record_t( chunk_carrier* chk_carr) :
|
||||
chunk_carrier_ptr(chk_carr) {};
|
||||
virtual ~chunk_manage_record_t() {};
|
||||
};
|
||||
|
||||
typedef chunk_manage_record_t* chunk_manage_recordPtr;
|
||||
|
||||
|
||||
class chunk_carrier
|
||||
{
|
||||
|
||||
public:
|
||||
chunk_carrier(int chunk_sz, int chunks);
|
||||
virtual ~chunk_carrier();
|
||||
|
||||
dlist* init_ptrs();
|
||||
|
||||
protected:
|
||||
int alloc_sz;
|
||||
int chunk_sz;
|
||||
int max_chunks;
|
||||
char* carrier_ptr;
|
||||
|
||||
friend class fix_chunk_pool;
|
||||
friend class memory_pool;
|
||||
};
|
||||
|
||||
|
||||
class fix_chunk_pool
|
||||
{
|
||||
|
||||
public:
|
||||
fix_chunk_pool(int chunk_sz);
|
||||
virtual ~fix_chunk_pool();
|
||||
|
||||
// return char*
|
||||
virtual char* alloc();
|
||||
|
||||
// free a char*
|
||||
virtual void free(char*);
|
||||
|
||||
protected:
|
||||
int chunk_sz;
|
||||
int chunks;
|
||||
dlist chunk_carrier_list;
|
||||
dlist free_chunk_list;
|
||||
|
||||
void init_one_chunk_carrier();
|
||||
};
|
||||
|
||||
|
||||
typedef void_ptr_array vm_pool_array_t;
|
||||
|
||||
class memory_pool
|
||||
{
|
||||
|
||||
public:
|
||||
memory_pool(int max_alloc_size = MAX_CHUNK_SZ);
|
||||
virtual ~memory_pool();
|
||||
|
||||
// return char*
|
||||
virtual char* alloc(size_t sz);
|
||||
|
||||
// free a char*
|
||||
virtual void free(char*);
|
||||
|
||||
protected:
|
||||
int max_alloc_size_from_pool;
|
||||
vm_pool_array_t vm_pool_vector;
|
||||
};
|
||||
|
||||
#ifdef C_API
|
||||
#define g_memory_pool (*g_memory_pool_ptr)
|
||||
extern memory_pool* g_memory_pool_ptr;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
30
cde/programs/dtinfo/DtMmdb/dstr/set.C
Normal file
30
cde/programs/dtinfo/DtMmdb/dstr/set.C
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* $XConsortium: set.cc /main/3 1996/06/11 17:17:36 cde-hal $
|
||||
*
|
||||
* 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 "set.h"
|
||||
|
||||
62
cde/programs/dtinfo/DtMmdb/dstr/set.h
Normal file
62
cde/programs/dtinfo/DtMmdb/dstr/set.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* $XConsortium: set.h /main/4 1996/06/11 17:17:41 cde-hal $
|
||||
*
|
||||
* 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 _set_h
|
||||
#define _set_h 1
|
||||
|
||||
#include "utility/funcs.h"
|
||||
|
||||
//**************************************************************
|
||||
//
|
||||
// an abstract set class
|
||||
//
|
||||
//**************************************************************
|
||||
|
||||
class set {
|
||||
|
||||
public:
|
||||
set(cmp_func_ptr_t eq, cmp_func_ptr_t ls) :
|
||||
f_cmp_func_eq(eq), f_cmp_func_ls(ls)
|
||||
{};
|
||||
virtual ~set() {};
|
||||
|
||||
virtual Boolean insert(void* element) = 0;
|
||||
virtual void* remove(void* element) = 0;
|
||||
virtual void* member(const void* element) = 0;
|
||||
|
||||
virtual void* smaller_member(const void* element) = 0;
|
||||
virtual void* larger_member(const void* element) = 0;
|
||||
|
||||
|
||||
protected:
|
||||
cmp_func_ptr_t f_cmp_func_eq;
|
||||
cmp_func_ptr_t f_cmp_func_ls;
|
||||
};
|
||||
|
||||
#endif
|
||||
126
cde/programs/dtinfo/DtMmdb/dstr/slist.C
Normal file
126
cde/programs/dtinfo/DtMmdb/dstr/slist.C
Normal file
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
* $XConsortium: slist.cc /main/4 1996/07/18 14:30:12 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
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "dstr/slist.h"
|
||||
#include "utility/funcs.h"
|
||||
|
||||
slist::slist(slist_cell* x) : v_ct(0), v_head(0), v_tail(0)
|
||||
{
|
||||
if ( x )
|
||||
insert_as_tail(x);
|
||||
}
|
||||
|
||||
slist::~slist()
|
||||
{
|
||||
slist_cell* y = 0;
|
||||
slist_cell* x = v_head;
|
||||
|
||||
while (x) {
|
||||
y = x -> v_succ;
|
||||
delete x;
|
||||
x = y;
|
||||
}
|
||||
}
|
||||
|
||||
void slist::append(slist* tail_list)
|
||||
{
|
||||
if ( tail_list == 0 ) return;
|
||||
|
||||
if ( v_tail != 0 )
|
||||
v_tail -> v_succ = tail_list -> v_head;
|
||||
|
||||
if ( v_head == 0 )
|
||||
v_head = tail_list -> v_head;
|
||||
|
||||
v_tail = tail_list -> v_tail;
|
||||
v_ct += tail_list -> v_ct;
|
||||
|
||||
tail_list -> v_head = tail_list -> v_tail = 0;
|
||||
tail_list -> v_ct = 0;
|
||||
}
|
||||
|
||||
void slist::insert_as_tail(slist_cell* x)
|
||||
{
|
||||
if ( v_head == 0 ) {
|
||||
v_head = v_tail = x;
|
||||
} else {
|
||||
v_tail -> v_succ = x;
|
||||
v_tail = x;
|
||||
}
|
||||
x -> v_succ = 0;
|
||||
v_ct++;
|
||||
}
|
||||
|
||||
void slist::delete_head()
|
||||
{
|
||||
if ( v_ct == 1 )
|
||||
v_head = v_tail = 0;
|
||||
else {
|
||||
v_head = v_head -> v_succ;
|
||||
}
|
||||
|
||||
v_ct--;
|
||||
}
|
||||
|
||||
long slist::first()
|
||||
{
|
||||
return long(v_head);
|
||||
}
|
||||
|
||||
long slist::last()
|
||||
{
|
||||
return long(v_tail);
|
||||
}
|
||||
|
||||
void slist::next(long& index)
|
||||
{
|
||||
if ( index == long(v_tail) )
|
||||
index = 0;
|
||||
else
|
||||
index = long( ((slist_cell*)(index)) -> v_succ );
|
||||
}
|
||||
|
||||
slist* slist::concate_with(slist* first_list ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start (ap, first_list);
|
||||
|
||||
this -> append(first_list);
|
||||
|
||||
for (;;) {
|
||||
slist* p = va_arg(ap, slist*);
|
||||
if ( p == 0 )
|
||||
break;
|
||||
else
|
||||
this -> append(p);
|
||||
}
|
||||
|
||||
va_end(ap);
|
||||
|
||||
return this;
|
||||
}
|
||||
82
cde/programs/dtinfo/DtMmdb/dstr/slist.h
Normal file
82
cde/programs/dtinfo/DtMmdb/dstr/slist.h
Normal file
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* $XConsortium: slist.h /main/4 1996/07/18 14:30:30 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 _slist_h
|
||||
#define _slist_h 1
|
||||
|
||||
#include <stdarg.h>
|
||||
#include "utility/debug.h"
|
||||
#include "dstr/slist_cell.h"
|
||||
|
||||
// single-linked list class
|
||||
|
||||
class slist {
|
||||
|
||||
public:
|
||||
slist(slist_cell* x = 0);
|
||||
virtual ~slist();
|
||||
|
||||
// append a slist. tail_list becomes part of this list. no copy
|
||||
// is performed. tail_list -> head and tail_list -> tail
|
||||
// are set to NULL. Also, tail_list -> ct = 0.
|
||||
void append(slist* tail_list);
|
||||
|
||||
// generalization of append(). arguments should be of type slist*.
|
||||
// this is returned
|
||||
slist* concate_with(slist* ...);
|
||||
|
||||
|
||||
// update functions
|
||||
void insert_as_tail(slist_cell* x) ;
|
||||
|
||||
void delete_head() ;
|
||||
void delete_tail() ;
|
||||
|
||||
// empty the list without free cells
|
||||
void empty_list() { v_head = v_tail = 0; v_ct = 0;} ;
|
||||
|
||||
// status function
|
||||
int count() { return v_ct; }; // number of cells in the list
|
||||
slist_cell* get_head() { return v_head; };
|
||||
slist_cell* get_tail() { return v_tail; };
|
||||
|
||||
long first(); // 0 if the list is empty
|
||||
void next(long & index);
|
||||
long last(); // 0 if the list is empty
|
||||
|
||||
protected:
|
||||
slist_cell *v_head; // head pointer
|
||||
slist_cell *v_tail; // tail pointer
|
||||
int v_ct; // cell in the list
|
||||
|
||||
};
|
||||
|
||||
typedef slist *slistPtr;
|
||||
|
||||
#endif
|
||||
49
cde/programs/dtinfo/DtMmdb/dstr/slist_cell.h
Normal file
49
cde/programs/dtinfo/DtMmdb/dstr/slist_cell.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* $XConsortium: slist_cell.h /main/3 1996/06/11 17:17:56 cde-hal $
|
||||
*
|
||||
* 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 _slist_cell_h
|
||||
#define _slist_cell_h 1
|
||||
|
||||
#include "utility/debug.h"
|
||||
|
||||
// single-linked list cell class
|
||||
|
||||
class slist_cell {
|
||||
|
||||
public:
|
||||
slist_cell() : v_succ(0) {};
|
||||
virtual ~slist_cell() {};
|
||||
|
||||
slist_cell *v_succ ; // succ pointer
|
||||
|
||||
};
|
||||
|
||||
typedef slist_cell *slist_cellPtr;
|
||||
|
||||
#endif
|
||||
36
cde/programs/dtinfo/DtMmdb/dstr/slist_char_ptr_cell.C
Normal file
36
cde/programs/dtinfo/DtMmdb/dstr/slist_char_ptr_cell.C
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* $XConsortium: slist_char_ptr_cell.cc /main/3 1996/06/11 17:18:01 cde-hal $
|
||||
*
|
||||
* 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 "dstr/slist_char_ptr_cell.h"
|
||||
|
||||
slist_char_ptr_cell::~slist_char_ptr_cell()
|
||||
{
|
||||
if ( v_alloca == true ) {
|
||||
delete (char*)data;
|
||||
}
|
||||
}
|
||||
56
cde/programs/dtinfo/DtMmdb/dstr/slist_char_ptr_cell.h
Normal file
56
cde/programs/dtinfo/DtMmdb/dstr/slist_char_ptr_cell.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* $XConsortium: slist_char_ptr_cell.h /main/3 1996/06/11 17:18:05 cde-hal $
|
||||
*
|
||||
* 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 _slist_char_ptr_cell_h
|
||||
#define _slist_char_ptr_cell_h 1
|
||||
|
||||
#include "utility/types.h"
|
||||
#include "dstr/slist_void_ptr_cell.h"
|
||||
|
||||
// single-linked list cell class, charPtr as data ptr.
|
||||
|
||||
class slist_char_ptr_cell : public slist_void_ptr_cell {
|
||||
|
||||
public:
|
||||
slist_char_ptr_cell(char* vp, Boolean allocated) :
|
||||
slist_void_ptr_cell(vp), v_alloca(allocated) {};
|
||||
virtual ~slist_char_ptr_cell() ;
|
||||
|
||||
char* char_ptr() { return (char*)data; };
|
||||
void set_char_ptr(char*x, Boolean allocated) {
|
||||
data = x;
|
||||
v_alloca = allocated;
|
||||
};
|
||||
|
||||
protected:
|
||||
Boolean v_alloca;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
53
cde/programs/dtinfo/DtMmdb/dstr/slist_void_ptr_cell.h
Normal file
53
cde/programs/dtinfo/DtMmdb/dstr/slist_void_ptr_cell.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* $XConsortium: slist_void_ptr_cell.h /main/3 1996/06/11 17:18:11 cde-hal $
|
||||
*
|
||||
* 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 _slist_void_ptr_cell_h
|
||||
#define _slist_void_ptr_cell_h 1
|
||||
|
||||
#include "utility/types.h"
|
||||
#include "dstr/slist_cell.h"
|
||||
|
||||
// single-linked list cell class, voidPtr as data ptr.
|
||||
|
||||
class slist_void_ptr_cell : public slist_cell {
|
||||
|
||||
public:
|
||||
slist_void_ptr_cell(voidPtr vp) : data(vp) {};
|
||||
virtual ~slist_void_ptr_cell() {};
|
||||
|
||||
voidPtr void_ptr() { return data; };
|
||||
void set_vptr(voidPtr x) { data = x; };
|
||||
|
||||
protected:
|
||||
voidPtr data;
|
||||
};
|
||||
|
||||
typedef slist_void_ptr_cell *slist_void_ptr_cellPtr;
|
||||
|
||||
#endif
|
||||
141
cde/programs/dtinfo/DtMmdb/dstr/token_stack.C
Normal file
141
cde/programs/dtinfo/DtMmdb/dstr/token_stack.C
Normal file
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
* $XConsortium: token_stack.C /main/5 1996/08/21 15:51:52 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
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "dstr/token_stack.h"
|
||||
|
||||
#ifdef C_API
|
||||
#include "utility/c_stream.h"
|
||||
#else
|
||||
#include <stream.h>
|
||||
#endif
|
||||
|
||||
token_stack::token_stack() : curr_token_start(0)
|
||||
{
|
||||
v_curr_token_buf = new buffer(LBUFSIZ);
|
||||
v_curr_list_cell = new slist_void_ptr_cell(v_curr_token_buf);
|
||||
chunk_list.insert_as_tail(v_curr_list_cell);
|
||||
}
|
||||
|
||||
token_stack::~token_stack()
|
||||
{
|
||||
long ind = chunk_list.first();
|
||||
while (ind) {
|
||||
slist_void_ptr_cell *p = (slist_void_ptr_cell*)ind;
|
||||
buffer *w = (buffer*)(p -> void_ptr());
|
||||
delete w;
|
||||
chunk_list.next(ind);
|
||||
}
|
||||
}
|
||||
|
||||
void token_stack::clear()
|
||||
{
|
||||
long ind = chunk_list.first();
|
||||
while (ind) {
|
||||
slist_void_ptr_cell *p = (slist_void_ptr_cell*)ind;
|
||||
buffer *w = (buffer*)(p -> void_ptr());
|
||||
w -> reset();
|
||||
chunk_list.next(ind);
|
||||
}
|
||||
|
||||
v_curr_list_cell = (slist_void_ptr_cell*)(chunk_list.get_head());
|
||||
v_curr_token_buf = (buffer*)(v_curr_list_cell -> void_ptr());
|
||||
}
|
||||
|
||||
void token_stack::new_token()
|
||||
{
|
||||
if ( curr_token_start )
|
||||
v_curr_token_buf -> put(char(0));
|
||||
|
||||
curr_token_start = 0;
|
||||
}
|
||||
|
||||
void token_stack::add_partial_token(char* x)
|
||||
{
|
||||
if ( v_curr_token_buf -> remaining_sz() < strlen(x) + 1) {
|
||||
|
||||
int partial_str_len = curr_token_start ? strlen(curr_token_start) : 0;
|
||||
|
||||
buffer* new_buf = 0;
|
||||
|
||||
slist_void_ptr_cell* next_cell =
|
||||
(slist_void_ptr_cell*)(v_curr_list_cell -> v_succ);
|
||||
|
||||
if ( next_cell ) {
|
||||
new_buf = (buffer*)(next_cell -> void_ptr());
|
||||
|
||||
} else {
|
||||
new_buf = new buffer(MAX(partial_str_len + 1, LBUFSIZ));
|
||||
next_cell = new slist_void_ptr_cell(new_buf);
|
||||
chunk_list.insert_as_tail(next_cell);
|
||||
}
|
||||
|
||||
if ( curr_token_start ) {
|
||||
v_curr_token_buf -> put(char(0));
|
||||
new_buf -> put(curr_token_start, strlen(curr_token_start));
|
||||
v_curr_token_buf -> set_content_sz(
|
||||
int(curr_token_start - v_curr_token_buf->get_base())
|
||||
);
|
||||
}
|
||||
|
||||
v_curr_list_cell = next_cell;
|
||||
v_curr_token_buf = new_buf;
|
||||
}
|
||||
|
||||
if ( curr_token_start == 0 ) {
|
||||
curr_token_start =
|
||||
v_curr_token_buf -> get_base() + v_curr_token_buf -> content_sz();
|
||||
}
|
||||
|
||||
v_curr_token_buf -> put(x, strlen(x));
|
||||
/*
|
||||
MESSAGE(cerr, "add_partial_token():");
|
||||
debug(cerr, last_buf -> content_sz());
|
||||
*/
|
||||
}
|
||||
|
||||
ostream& operator <<(ostream& out, token_stack& ts)
|
||||
{
|
||||
long ind = ts.chunk_list.first();
|
||||
while (ind) {
|
||||
slist_void_ptr_cell *p = (slist_void_ptr_cell*)ind;
|
||||
buffer *w = (buffer*)(p -> void_ptr());
|
||||
|
||||
int offset = 0;
|
||||
while ( offset < w -> content_sz() ) {
|
||||
|
||||
char* str = (char*)(w -> get_base() + offset);
|
||||
out << str << "\n";
|
||||
|
||||
offset += strlen(str) + 1;
|
||||
}
|
||||
|
||||
ts.chunk_list.next(ind);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
62
cde/programs/dtinfo/DtMmdb/dstr/token_stack.h
Normal file
62
cde/programs/dtinfo/DtMmdb/dstr/token_stack.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* $XConsortium: token_stack.h /main/3 1996/06/11 17:18:21 cde-hal $
|
||||
*
|
||||
* 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 _token_stack_h
|
||||
#define _token_stack_h 1
|
||||
|
||||
#include "utility/debug.h"
|
||||
#include "utility/buffer.h"
|
||||
#include "dstr/slist.h"
|
||||
#include "dstr/slist_void_ptr_cell.h"
|
||||
|
||||
class token_stack
|
||||
{
|
||||
public:
|
||||
token_stack();
|
||||
virtual ~token_stack();
|
||||
|
||||
void clear();
|
||||
|
||||
void new_token();
|
||||
void add_partial_token(char*);
|
||||
|
||||
char* token_start() { return curr_token_start; };
|
||||
|
||||
friend ostream& operator <<(ostream&, token_stack&);
|
||||
|
||||
protected:
|
||||
slist chunk_list;
|
||||
char* curr_token_start;
|
||||
buffer* v_curr_token_buf;
|
||||
slist_void_ptr_cell * v_curr_list_cell;
|
||||
};
|
||||
|
||||
typedef token_stack *token_stackPtr;
|
||||
|
||||
#endif
|
||||
94
cde/programs/dtinfo/DtMmdb/dstr/void_ptr_array.C
Normal file
94
cde/programs/dtinfo/DtMmdb/dstr/void_ptr_array.C
Normal file
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* $XConsortium: void_ptr_array.cc /main/4 1996/07/18 14:31:06 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
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "void_ptr_array.h"
|
||||
|
||||
void_ptr_array::void_ptr_array(void_ptr_array& original) :
|
||||
buffer(original), v_elmts(original.v_elmts)
|
||||
{
|
||||
}
|
||||
|
||||
void_ptr_array::void_ptr_array(int exp_sz) :
|
||||
buffer(exp_sz * sizeof(voidPtr)), v_elmts(0)
|
||||
{
|
||||
memset(get_base(), (char)0, buf_sz());
|
||||
}
|
||||
|
||||
Boolean void_ptr_array::expandWith(int extra_void_ptrs)
|
||||
{
|
||||
return buffer::expand_chunk( (count() + extra_void_ptrs) * sizeof(void*) );
|
||||
}
|
||||
|
||||
/*
|
||||
void void_ptr_array::reset_v_elmts(int i)
|
||||
{
|
||||
v_elmts = i;
|
||||
}
|
||||
|
||||
int void_ptr_array::no_v_elmts()
|
||||
{
|
||||
return v_elmts;
|
||||
}
|
||||
*/
|
||||
|
||||
Boolean void_ptr_array::insert(void* elmt, int i)
|
||||
{
|
||||
/*
|
||||
MESSAGE(cerr, "INSERT to void_ptr_array");
|
||||
debug(cerr, int(i));
|
||||
debug(cerr, int(elmt));
|
||||
*/
|
||||
|
||||
if ( !INRANGE(i, 0, count()-1) ) {
|
||||
expandWith( 2*i - count() );
|
||||
}
|
||||
|
||||
memcpy(
|
||||
v_base + i * sizeof(voidPtr),
|
||||
(char*)&elmt,
|
||||
sizeof(elmt)
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void void_ptr_array::reset_vptr(voidPtr v)
|
||||
{
|
||||
for ( int i=0; i<count(); i++) {
|
||||
insert(v, i);
|
||||
}
|
||||
}
|
||||
|
||||
ostream& operator <<(ostream& out, void_ptr_array& va)
|
||||
{
|
||||
for (int i=0; i<va.no_elmts(); i++) {
|
||||
out << long(va[i]) << " ";
|
||||
}
|
||||
out << "\n";
|
||||
return out;
|
||||
}
|
||||
85
cde/programs/dtinfo/DtMmdb/dstr/void_ptr_array.h
Normal file
85
cde/programs/dtinfo/DtMmdb/dstr/void_ptr_array.h
Normal file
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* $XConsortium: void_ptr_array.h /main/4 1996/07/18 14:31:24 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 _void_ptr_array_h
|
||||
#define _void_ptr_array_h 1
|
||||
|
||||
#include "utility/funcs.h"
|
||||
#include "utility/buffer.h"
|
||||
|
||||
//**************************************************************
|
||||
//
|
||||
// an void_ptr_array class
|
||||
// holding voidPtr elements in range [0, count()-1]
|
||||
//
|
||||
//**************************************************************
|
||||
|
||||
class void_ptr_array : public buffer
|
||||
{
|
||||
|
||||
public:
|
||||
void_ptr_array(int exp_size) ;
|
||||
void_ptr_array(void_ptr_array&) ;
|
||||
virtual ~void_ptr_array() {};
|
||||
|
||||
Boolean expandWith(int extra_void_ptrs);
|
||||
|
||||
Boolean insert(void* element, int i) ;
|
||||
|
||||
void reset_vptr(voidPtr value); // set all cells to value
|
||||
|
||||
inline void reset_elmts(int i) { v_elmts = i; };
|
||||
inline int no_elmts() { return v_elmts; };
|
||||
|
||||
inline int count() {
|
||||
return (buf_sz() / sizeof(voidPtr) );
|
||||
};
|
||||
|
||||
// terminate value: -1
|
||||
inline int first() {
|
||||
return ( count() == 0 ) ? -1 : 0;
|
||||
};
|
||||
inline virtual void* operator [](int i) {
|
||||
return ((voidPtr*)(v_base))[i] ;
|
||||
};
|
||||
inline void next(int& ind) {
|
||||
if ( ind == count() -1 )
|
||||
ind = -1;
|
||||
else
|
||||
ind++;
|
||||
};
|
||||
|
||||
friend ostream& operator <<(ostream&, void_ptr_array&);
|
||||
|
||||
protected:
|
||||
|
||||
int v_elmts;
|
||||
};
|
||||
|
||||
#endif
|
||||
70
cde/programs/dtinfo/DtMmdb/dstr/void_ptr_stack.C
Normal file
70
cde/programs/dtinfo/DtMmdb/dstr/void_ptr_stack.C
Normal file
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* $XConsortium: void_ptr_stack.cc /main/3 1996/06/11 17:18:35 cde-hal $
|
||||
*
|
||||
* 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 "dstr/void_ptr_stack.h"
|
||||
|
||||
void_ptr_stack::void_ptr_stack(int exp_size) :
|
||||
void_ptr_array(exp_size)
|
||||
{
|
||||
}
|
||||
|
||||
void_ptr_stack::~void_ptr_stack()
|
||||
{
|
||||
}
|
||||
|
||||
void void_ptr_stack::push(void* new_elmt)
|
||||
{
|
||||
insert(new_elmt, v_elmts++);
|
||||
}
|
||||
|
||||
void* void_ptr_stack::pop()
|
||||
{
|
||||
if ( v_elmts == 0 )
|
||||
throw(stringException("empty stack"));
|
||||
|
||||
return operator[](--v_elmts);
|
||||
}
|
||||
|
||||
void* void_ptr_stack::peep(int i)
|
||||
{
|
||||
if INRANGE(i, -(v_elmts-1), 0) {
|
||||
return operator[](v_elmts-i-1);
|
||||
} else {
|
||||
debug(cerr, i);
|
||||
debug(cerr, v_elmts);
|
||||
throw(stringException("invalid peep index"));
|
||||
}
|
||||
}
|
||||
|
||||
ostream& operator <<(ostream& out, void_ptr_stack& stk)
|
||||
{
|
||||
for ( int i=stk.no_elmts(); i>0; i-- )
|
||||
debug(cerr, (char*)stk.operator[](i-1));
|
||||
return out;
|
||||
}
|
||||
|
||||
57
cde/programs/dtinfo/DtMmdb/dstr/void_ptr_stack.h
Normal file
57
cde/programs/dtinfo/DtMmdb/dstr/void_ptr_stack.h
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* $XConsortium: void_ptr_stack.h /main/3 1996/06/11 17:18:40 cde-hal $
|
||||
*
|
||||
* 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 _void_ptr_stack_h
|
||||
#define _void_ptr_stack_h 1
|
||||
|
||||
#include "dstr/void_ptr_array.h"
|
||||
|
||||
//**************************************************************
|
||||
//
|
||||
// A void_ptr_stack class
|
||||
//
|
||||
//**************************************************************
|
||||
|
||||
class void_ptr_stack : public void_ptr_array
|
||||
{
|
||||
|
||||
public:
|
||||
void_ptr_stack(int exp_size) ;
|
||||
virtual ~void_ptr_stack();
|
||||
|
||||
void push(void*);
|
||||
void* pop();
|
||||
void* peep(int i);
|
||||
|
||||
friend ostream& operator <<(ostream&, void_ptr_stack&);
|
||||
|
||||
protected:
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user