source410: literal 4.10 source reconstruction + BC++ 4.52 fleet toolchain archived

- BORLAND/: Borland C++ 4.52 (chosen over 4.5 by byte-match: CODE/RP/CW32.LIB
  is identical to 4.52's install lib). BCC32/TLINK32/TLIB/MAKE run natively on
  Win11; CODE/BT/OPT.MAK is the shipped BTL4OPT.EXE's exact flag recipe
  (extender = Borland PowerPack DPMI32, not Phar Lap TNT).
- restoration/source410/: the literal 1995-form reconstruction of the missing
  BT game source (never mixed into CODE/). Round 1-3 state:
  * 6 of 10 surviving original TUs COMPILE CLEAN under the period toolchain
    (BTMSSN, BTCNSL, BTSCNRL, BTTEAM, BTL4MODE, BTL4ARND) - first builds
    since 1996.
  * BT_L4/BTL4APP.CPP pilot reconstruction: 12/12 functions, Fail() lands on
    its binary-recorded line 400 exactly.
  * BT/BTCNSL.HPP: console wire IDs recovered from the binary's ctors
    (Killed=9, Damaged=10, ScoreUpdate=13, DeathWithoutHonor=15 [T1];
    TeamScore=12 flagged [T4]).
  * MUNGA/: 8 engine-header backfills back-dated from the BT412 WinTesla tree
    (VDATA numbering decomp-verified; AUDREND's OpenAL-era virtual removed -
    the period compiler is the drift detector).
  * Tooling: backdate.py (WinTesla->1995 header transform), compile410.sh
    (per-TU verification sweep under authentic OPT.MAK flags).
  * README: corrected roadmap - MECH.HPP is the capstone grown with the mech
    TU reconstructions; BTREG.CPP green = the header-family milestone.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Cyd
2026-07-19 07:33:26 -05:00
co-authored by Claude Fable 5
parent 599b2388a1
commit 63312e07f9
5913 changed files with 756089 additions and 0 deletions
@@ -0,0 +1,64 @@
// ---------------------------------------------------------------------------
// Copyright (C) 1994 Borland International
// array.cpp
// Must link with myclass.cpp.
// ---------------------------------------------------------------------------
#include <classlib/arrays.h>
#include <iostream.h>
#include <strstrea.h>
#include "../myclass.h"
typedef TArrayAsVector<MyClass> ContainerType;
typedef TArrayAsVectorIterator<MyClass> IteratorType;
const int MaxItems=6;
void ForEachCallBack(MyClass& mc, void* s)
{
cout << (char*)s << mc << endl;
}
void AddItems(ContainerType& container, int numItems)
{
for( int i=numItems; i>0; i-- )
{
char buf[80];
ostrstream str( buf, sizeof(buf) );
str << i << " hello" << ends;
container.Add(MyClass(buf));
}
}
void UseForwardIterator(ContainerType& container)
{
IteratorType iterator(container);
while( iterator )
{
cout << iterator.Current() << endl;
iterator++;
}
}
void UseIndex(ContainerType& container)
{
for( int i=container.LowerBound(); i<container.UpperBound(); i++ )
cout << container[i] << endl;
}
int main()
{
ContainerType container(MaxItems);
AddItems(container, MaxItems);
cout << "--- Starting ForEach" << endl;
container.ForEach(ForEachCallBack, (void*)"FE ");
cout << "--- Starting Iterator (forward)" << endl;
UseForwardIterator(container);
cout << "--- Using operator[]" << endl;
UseIndex(container);
return 0;
}
@@ -0,0 +1,64 @@
// ---------------------------------------------------------------------------
// Copyright (C) 1994 Borland International
// iarray.cpp
// Must link with myclass.cpp.
// ---------------------------------------------------------------------------
#include <classlib/arrays.h>
#include <iostream.h>
#include <strstrea.h>
#include "../myclass.h"
typedef TIArrayAsVector<MyClass> ContainerType;
typedef TIArrayAsVectorIterator<MyClass> IteratorType;
const int MaxItems=6;
void ForEachCallBack(MyClass& mc, void* s)
{
cout << (char*)s << mc << endl;
}
void AddItems(ContainerType& container, int numItems)
{
for( int i=numItems; i>0; i-- )
{
char buf[80];
ostrstream str( buf, sizeof(buf) );
str << i << " hello" << ends;
container.Add( new MyClass(buf) );
}
}
void UseForwardIterator(ContainerType& container)
{
IteratorType iterator(container);
while( iterator )
{
cout << *iterator.Current() << endl;
iterator++;
}
}
void UseIndex(ContainerType& container)
{
for( int i=container.LowerBound(); i<container.UpperBound(); i++ )
cout << *container[i] << endl;
}
int main()
{
ContainerType container(MaxItems);
AddItems(container, MaxItems);
cout << "--- Starting ForEach" << endl;
container.ForEach(ForEachCallBack, (void*)"FE ");
cout << "--- Starting Iterator (forward)" << endl;
UseForwardIterator(container);
cout << "--- Using operator[]" << endl;
UseIndex(container);
return 0;
}
@@ -0,0 +1,64 @@
// ---------------------------------------------------------------------------
// Copyright (C) 1994 Borland International
// isarray.cpp
// Must link with myclass.cpp.
// ---------------------------------------------------------------------------
#include <classlib/arrays.h>
#include <iostream.h>
#include <strstrea.h>
#include "../myclass.h"
typedef TIArrayAsVector<MyClass> ContainerType;
typedef TIArrayAsVectorIterator<MyClass> IteratorType;
const int MaxItems=6;
void ForEachCallBack(MyClass& mc, void* s)
{
cout << (char*)s << mc << endl;
}
void AddItems(ContainerType& container, int numItems)
{
for( int i=numItems; i>0; i-- )
{
char buf[80];
ostrstream str( buf, sizeof(buf) );
str << i << " hello" << ends;
container.Add( new MyClass(buf) );
}
}
void UseForwardIterator(ContainerType& container)
{
IteratorType iterator(container);
while( iterator )
{
cout << *iterator.Current() << endl;
iterator++;
}
}
void UseIndex(ContainerType& container)
{
for( int i=container.LowerBound(); i<container.UpperBound(); i++ )
cout << *container[i] << endl;
}
int main()
{
ContainerType container(MaxItems);
AddItems(container, MaxItems);
cout << "--- Starting ForEach" << endl;
container.ForEach(ForEachCallBack, (void*)"FE ");
cout << "--- Starting Iterator (forward)" << endl;
UseForwardIterator(container);
cout << "--- Using operator[]" << endl;
UseIndex(container);
return 0;
}
@@ -0,0 +1,30 @@
#--------------------------------------------------------------------------#
# #
# MAKEFILE for ARRAY examples #
# #
# Copyright (c) 1994 Borland International #
# All Rights Reserved #
# #
# Usage: #
# #
# make -DCON32 for 32-bit Windows Console #
# make MODEL={s|m|c|l} for 16-bit Windows using EasyWin #
# make MODEL={s|m|c|l|h} -DDOS16 for 16-bit DOS #
# #
#--------------------------------------------------------------------------#
EXE = array
EXEALL = array.exe iarray.exe sarray.exe isarray.exe
EXEMAKE= $(ARRAY) $(IARRAY) $(SARRAY) $(ISARRAY)
RULES = myclass.obj: ..\myclass.cpp
ARRAY=$(EXERULE:array.obj=array.obj myclass.obj)
IARRAY=$(ARRAY:array=iarray)
SARRAY=$(ARRAY:array=sarray)
ISARRAY=$(ARRAY:array=isarray)
!include $(BCEXAMPLEDIR)\bidsmake.gen
@@ -0,0 +1,64 @@
// ---------------------------------------------------------------------------
// Copyright (C) 1994 Borland International
// sarray.cpp
// Must link with myclass.cpp.
// ---------------------------------------------------------------------------
#include <classlib/arrays.h>
#include <iostream.h>
#include <strstrea.h>
#include "../myclass.h"
typedef TSArrayAsVector<MyClass> ContainerType;
typedef TSArrayAsVectorIterator<MyClass> IteratorType;
const int MaxItems=6;
void ForEachCallBack(MyClass& mc, void* s)
{
cout << (char*)s << mc << endl;
}
void AddItems(ContainerType& container, int numItems)
{
for( int i=numItems; i>0; i-- )
{
char buf[80];
ostrstream str( buf, sizeof(buf) );
str << i << " hello" << ends;
container.Add(MyClass(buf));
}
}
void UseForwardIterator(ContainerType& container)
{
IteratorType iterator(container);
while( iterator )
{
cout << iterator.Current() << endl;
iterator++;
}
}
void UseIndex(ContainerType& container)
{
for( int i=container.LowerBound(); i<container.UpperBound(); i++ )
cout << container[i] << endl;
}
int main()
{
ContainerType container(MaxItems);
AddItems(container, MaxItems);
cout << "--- Starting ForEach" << endl;
container.ForEach(ForEachCallBack, (void*)"FE ");
cout << "--- Starting Iterator (forward)" << endl;
UseForwardIterator(container);
cout << "--- Using operator[]" << endl;
UseIndex(container);
return 0;
}
@@ -0,0 +1,65 @@
// ---------------------------------------------------------------------------
// Copyright (C) 1994 Borland International
// assocdd.cpp
// Must link with myclass.cpp.
// ---------------------------------------------------------------------------
#include <classlib/assoc.h>
#include <classlib/dict.h>
#include <iostream.h>
#include <strstrea.h>
#include "../myclass.h"
typedef TDDAssociation<MyClass, MyValue> AssociationType;
typedef TDictionaryAsHashTable<AssociationType> ContainerType;
typedef TDictionaryAsHashTableIterator<AssociationType> IteratorType;
const int MaxItems=6;
void ForEachCallBack(AssociationType& at, void* s)
{
cout << (char*)s << at.Key() << ", " << at.Value() << endl;
}
void AddItems(ContainerType& container, int numItems)
{
for( int i=numItems; i>0; i-- )
{
char buf1[10];
ostrstream out1( buf1, sizeof(buf1) );
out1 << i << ends;
MyClass mc(buf1);
char buf2[10];
ostrstream out2( buf2, sizeof(buf2) );
out2 << "hello " << i << ends;
MyValue mv(buf2);
AssociationType assoc(mc, mv);
container.Add(assoc);
}
}
void UseForwardIterator(ContainerType& container)
{
IteratorType iterator(container);
while( iterator )
{
const AssociationType& at = iterator.Current();
cout << at.Key() << ", " << at.Value() << endl;
iterator++;
}
}
int main()
{
ContainerType container(MaxItems);
AddItems(container, MaxItems);
cout << "--- Starting ForEach" << endl;
container.ForEach(ForEachCallBack, (void*)"FE ");
cout << "--- Starting Iterator (forward)" << endl;
UseForwardIterator(container);
return 0;
}
@@ -0,0 +1,65 @@
// ---------------------------------------------------------------------------
// Copyright (C) 1994 Borland International
// assocdi.cpp
// Must link with myclass.cpp.
// ---------------------------------------------------------------------------
#include <classlib/assoc.h>
#include <classlib/dict.h>
#include <iostream.h>
#include <strstrea.h>
#include "../myclass.h"
typedef TDIAssociation<MyClass, MyValue> AssociationType;
typedef TDictionaryAsHashTable<AssociationType> ContainerType;
typedef TDictionaryAsHashTableIterator<AssociationType> IteratorType;
const int MaxItems=6;
void ForEachCallBack(AssociationType& at, void* s)
{
cout << (char *)s << at.Key() << ", " << *at.Value() << endl;
}
void AddItems(ContainerType& container, int numItems)
{
for( int i=numItems; i>0; i-- )
{
char buf1[10];
ostrstream out1( buf1, sizeof(buf1) );
out1 << i << ends;
MyClass mc(buf1);
char buf2[10];
ostrstream out2( buf2, sizeof(buf2) );
out2 << "hello " << i << ends;
MyValue mv(buf2);
AssociationType assoc(mc, new MyValue(mv) );
container.Add(assoc);
}
}
void UseForwardIterator(ContainerType& container)
{
IteratorType iterator(container);
while( iterator )
{
const AssociationType& at = iterator.Current();
cout << at.Key() << ", " << *at.Value() << endl;
iterator++;
}
}
int main()
{
ContainerType container(MaxItems);
AddItems(container, MaxItems);
cout << "--- Starting ForEach" << endl;
container.ForEach(ForEachCallBack, (void*)"FE ");
cout << "--- Starting Iterator (forward)" << endl;
UseForwardIterator(container);
return 0;
}
@@ -0,0 +1,65 @@
// ---------------------------------------------------------------------------
// Copyright (C) 1994 Borland International
// associd.cpp
// Must link with myclass.cpp.
// ---------------------------------------------------------------------------
#include <classlib/assoc.h>
#include <classlib/dict.h>
#include <iostream.h>
#include <strstrea.h>
#include "../myclass.h"
typedef TIDAssociation<MyClass, MyValue> AssociationType;
typedef TDictionaryAsHashTable<AssociationType> ContainerType;
typedef TDictionaryAsHashTableIterator<AssociationType> IteratorType;
const int MaxItems=6;
void ForEachCallBack(AssociationType& at, void* s)
{
cout << (char*)s << *at.Key() << ", " << at.Value() << endl;
}
void AddItems(ContainerType& container, int numItems)
{
for( int i=numItems; i>0; i-- )
{
char buf1[10];
ostrstream out1( buf1, sizeof(buf1) );
out1 << i << ends;
MyClass mc(buf1);
char buf2[10];
ostrstream out2( buf2, sizeof(buf2) );
out2 << "hello " << i << ends;
MyValue mv(buf2);
AssociationType assoc( new MyClass(mc), mv);
container.Add(assoc);
}
}
void UseForwardIterator(ContainerType& container)
{
IteratorType iterator(container);
while( iterator )
{
const AssociationType& at = iterator.Current();
cout << *at.Key() << ", " << at.Value() << endl;
iterator++;
}
}
int main()
{
ContainerType container(MaxItems);
AddItems(container, MaxItems);
cout << "--- Starting ForEach" << endl;
container.ForEach(ForEachCallBack, (void*)"FE ");
cout << "--- Starting Iterator (forward)" << endl;
UseForwardIterator(container);
return 0;
}
@@ -0,0 +1,65 @@
// ---------------------------------------------------------------------------
// Copyright (C) 1994 Borland International
// associdd.cpp
// Must link with myclass.cpp.
// ---------------------------------------------------------------------------
#include <classlib/assoc.h>
#include <classlib/dict.h>
#include <iostream.h>
#include <strstrea.h>
#include "../myclass.h"
typedef TDDAssociation<MyClass, MyValue> AssociationType;
typedef TIDictionaryAsHashTable<AssociationType> ContainerType;
typedef TIDictionaryAsHashTableIterator<AssociationType> IteratorType;
const int MaxItems=6;
void ForEachCallBack(AssociationType& at, void* s)
{
cout << (char*)s << at.Key() << ", " << at.Value() << endl;
}
void AddItems(ContainerType& container, int numItems)
{
for( int i=numItems; i>0; i-- )
{
char buf1[10];
ostrstream out1( buf1, sizeof(buf1) );
out1 << i << ends;
MyClass mc(buf1);
char buf2[10];
ostrstream out2( buf2, sizeof(buf2) );
out2 << "hello " << i << ends;
MyValue mv(buf2);
AssociationType assoc(mc, mv);
container.Add( new AssociationType(assoc) );
}
}
void UseForwardIterator(ContainerType &container)
{
IteratorType iterator(container);
while (iterator)
{
const AssociationType* at = iterator.Current();
cout << at->Key() << ", " << at->Value() << endl;
iterator++;
}
}
int main()
{
ContainerType container(MaxItems);
AddItems(container, MaxItems);
cout << "--- Starting ForEach" << endl;
container.ForEach(ForEachCallBack, (void*)"FE ");
cout << "--- Starting Iterator (forward)" << endl;
UseForwardIterator(container);
return 0;
}
@@ -0,0 +1,65 @@
// ---------------------------------------------------------------------------
// Copyright (C) 1994 Borland International
// associi.cpp
// Must link with myclass.cpp.
// ---------------------------------------------------------------------------
#include <classlib/assoc.h>
#include <classlib/dict.h>
#include <iostream.h>
#include <strstrea.h>
#include "../myclass.h"
typedef TIIAssociation<MyClass, MyValue> AssociationType;
typedef TDictionaryAsHashTable<AssociationType> ContainerType;
typedef TDictionaryAsHashTableIterator<AssociationType> IteratorType;
const int MaxItems=6;
void ForEachCallBack(AssociationType& at, void* s)
{
cout << (char*)s << *at.Key() << ", " << *at.Value() << endl;
}
void AddItems(ContainerType& container, int numItems)
{
for( int i=numItems; i>0; i-- )
{
char buf1[10];
ostrstream out1( buf1, sizeof(buf1) );
out1 << i << ends;
MyClass mc(buf1);
char buf2[10];
ostrstream out2( buf2, sizeof(buf2) );
out2 << "hello " << i << ends;
MyValue mv(buf2);
AssociationType assoc( new MyClass(mc), new MyValue(mv) );
container.Add(assoc);
}
}
void UseForwardIterator(ContainerType& container)
{
IteratorType iterator(container);
while( iterator )
{
const AssociationType& at = iterator.Current();
cout << *at.Key() << ", " << *at.Value() << endl;
iterator++;
}
}
int main()
{
ContainerType container(MaxItems);
AddItems(container, MaxItems);
cout << "--- Starting ForEach" << endl;
container.ForEach(ForEachCallBack, (void*)"FE ");
cout << "--- Starting Iterator (forward)" << endl;
UseForwardIterator(container);
return 0;
}
@@ -0,0 +1,31 @@
#--------------------------------------------------------------------------#
# #
# MAKEFILE for ARRAY examples #
# #
# Copyright (c) 1994 Borland International #
# All Rights Reserved #
# #
# Usage: #
# #
# make -DCON32 for 32-bit Windows Console #
# make MODEL={s|m|c|l} for 16-bit Windows using EasyWin #
# make MODEL={s|m|c|l|h} -DDOS16 for 16-bit DOS #
# #
#--------------------------------------------------------------------------#
EXE = assocdd
EXEALL = assocdd.exe assocdi.exe associd.exe associi.exe associdd.exe
EXEMAKE= $(ASSOCDD) $(ASSOCDI) $(ASSOCID) $(ASSOCII) $(ASSOCIDD)
RULES = myclass.obj: ..\myclass.cpp
ASSOCDD=$(EXERULE:assocdd.obj=assocdd.obj myclass.obj)
ASSOCDI=$(ASSOCDD:assocdd=assocdi)
ASSOCID=$(ASSOCDD:assocdd=associd)
ASSOCII=$(ASSOCDD:assocdd=associi)
ASSOCIDD=$(ASSOCDD:assocdd=associdd)
!include $(BCEXAMPLEDIR)\bidsmake.gen
@@ -0,0 +1,56 @@
// ---------------------------------------------------------------------------
// Copyright (C) 1994 Borland International
// bag.cpp
// Must link with myclass.cpp.
// ---------------------------------------------------------------------------
#include <classlib/bags.h>
#include <iostream.h>
#include <strstrea.h>
#include "../myclass.h"
typedef TBagAsVector<MyClass> ContainerType;
typedef TBagAsVectorIterator<MyClass> IteratorType;
const int MaxItems=6;
void ForEachCallBack(MyClass& mc, void* s)
{
cout << (char*)s << mc << endl;
}
void AddItems(ContainerType& container, int numItems)
{
for( int i=numItems; i>0; i-- )
{
char buf[80];
ostrstream str( buf, sizeof(buf) );
str << i << " hello" << ends;
MyClass tempItem( buf );
container.Add(tempItem);
}
}
void UseForwardIterator(ContainerType& container)
{
IteratorType iterator(container);
while( iterator )
{
cout << iterator.Current() << endl;
iterator++;
}
}
int main()
{
ContainerType container(MaxItems);
AddItems(container, MaxItems);
cout << "--- Starting ForEach" << endl;
container.ForEach(ForEachCallBack, (void*)"FE ");
cout << "--- Starting Iterator (forward)" << endl;
UseForwardIterator(container);
return 0;
}
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,55 @@
// ---------------------------------------------------------------------------
// Copyright (C) 1994 Borland International
// ibag.cpp
// Must link with myclass.cpp.
// ---------------------------------------------------------------------------
#include <classlib/bags.h>
#include <iostream.h>
#include <strstrea.h>
#include "../myclass.h"
typedef TIBagAsVector<MyClass> ContainerType;
typedef TIBagAsVectorIterator<MyClass> IteratorType;
const int MaxItems=6;
void ForEachCallBack(MyClass& mc, void* s)
{
cout << (char*)s << mc << endl;
}
void AddItems(ContainerType& container, int numItems)
{
for( int i=numItems; i>0; i-- )
{
char buf[80];
ostrstream str( buf, sizeof(buf) );
str << i << " hello" << ends;
container.Add( new MyClass(buf) );
}
}
void UseForwardIterator(ContainerType& container)
{
IteratorType iterator(container);
while( iterator )
{
cout << *iterator.Current() << endl;
iterator++;
}
}
int main()
{
ContainerType container(MaxItems);
AddItems(container, MaxItems);
cout << "--- Starting ForEach" << endl;
container.ForEach(ForEachCallBack, (void*)"FE ");
cout << "--- Starting Iterator (forward)" << endl;
UseForwardIterator(container);
return 0;
}
Binary file not shown.
@@ -0,0 +1,28 @@
#--------------------------------------------------------------------------#
# #
# MAKEFILE for BAG examples #
# #
# Copyright (c) 1994 Borland International #
# All Rights Reserved #
# #
# Usage: #
# #
# make -DCON32 for 32-bit Windows Console #
# make MODEL={s|m|c|l} for 16-bit Windows using EasyWin #
# make MODEL={s|m|c|l|h} -DDOS16 for 16-bit DOS #
# #
#--------------------------------------------------------------------------#
EXE = bag
EXEALL = bag.exe ibag.exe
EXEMAKE= $(BAG) $(IBAG)
RULES = myclass.obj: ..\myclass.cpp
BAG=$(EXERULE:bag.obj=bag.obj myclass.obj)
IBAG=$(BAG:bag=ibag)
!include $(BCEXAMPLEDIR)\bidsmake.gen
@@ -0,0 +1,83 @@
// ---------------------------------------------------------------------------
// Copyright (C) 1994 Borland International
// bintree.cpp
// Must link with myclass.cpp.
// ---------------------------------------------------------------------------
#include <classlib/binimp.h>
#include <iostream.h>
#include <strstrea.h>
#include "../myclass.h"
typedef TBinarySearchTreeImp<MyClass> ContainerType;
typedef TBinarySearchTreeIteratorImp<MyClass> IteratorType;
const int MaxItems=6;
void ForEachCallBack(MyClass& mc, void *s)
{
cout << (char *)s << mc << endl;
}
void AddItems(ContainerType& container, int numItems)
{
int multiplier = 1;
for( int i=numItems; i>0; i-- )
{
char buf[80];
ostrstream str(buf, sizeof(buf) );
str << (numItems-multiplier*i) << " hello" << ends;
multiplier = -1 * multiplier;
container.Add(MyClass(buf));
}
}
void UseInorderIterator(ContainerType& container)
{
IteratorType iterator(container);
while( iterator )
{
cout << iterator.Current() << endl;
iterator++;
}
}
void UsePreorderIterator(ContainerType& container)
{
IteratorType iterator(container, TBinarySearchTreeBase::PreOrder);
while( iterator )
{
cout << iterator.Current() << endl;
iterator++;
}
}
void UsePostorderIterator(ContainerType& container)
{
IteratorType iterator(container, TBinarySearchTreeBase::PostOrder);
while( iterator )
{
cout << iterator.Current() << endl;
iterator++;
}
}
int main()
{
ContainerType container;
AddItems(container, MaxItems);
cout << "--- Starting ForEach" << endl;
container.ForEach(ForEachCallBack, (void*)"FE ");
cout << "--- Starting Iterator (inorder)" << endl;
UseInorderIterator(container);
cout << "--- Starting Iterator (preorder)" << endl;
UsePreorderIterator(container);
cout << "--- Starting Iterator (postorder)" << endl;
UsePostorderIterator(container);
return 0;
}
@@ -0,0 +1,83 @@
// ---------------------------------------------------------------------------
// Copyright (C) 1994 Borland International
// ibintree.cpp
// Must link with myclass.cpp.
// ---------------------------------------------------------------------------
#include <classlib/binimp.h>
#include <iostream.h>
#include <strstrea.h>
#include "../myclass.h"
typedef TIBinarySearchTreeImp<MyClass> ContainerType;
typedef TIBinarySearchTreeIteratorImp<MyClass> IteratorType;
const int MaxItems=6;
void ForEachCallBack(MyClass& mc, void* s)
{
cout << (char*)s << mc << endl;
}
void AddItems(ContainerType& container, int numItems)
{
int multiplier = 1;
for( int i=numItems; i>0; i-- )
{
char buf[80];
ostrstream str( buf, sizeof(buf) );
str << (numItems-multiplier*i) << " hello" << ends;
multiplier = -1 * multiplier;
container.Add( new MyClass(buf) );
}
}
void UseInorderIterator(ContainerType& container)
{
IteratorType iterator(container);
while( iterator )
{
cout << *iterator.Current() << endl;
iterator++;
}
}
void UsePreorderIterator(ContainerType& container)
{
IteratorType iterator(container, TBinarySearchTreeBase::PreOrder);
while( iterator )
{
cout << *iterator.Current() << endl;
iterator++;
}
}
void UsePostorderIterator(ContainerType& container)
{
IteratorType iterator(container, TBinarySearchTreeBase::PostOrder);
while( iterator )
{
cout << *iterator.Current() << endl;
iterator++;
}
}
int main()
{
ContainerType container;
AddItems(container, MaxItems);
cout << "--- Starting ForEach" << endl;
container.ForEach(ForEachCallBack, (void*)"FE ");
cout << "--- Starting Iterator (inorder)" << endl;
UseInorderIterator(container);
cout << "--- Starting Iterator (preorder)" << endl;
UsePreorderIterator(container);
cout << "--- Starting Iterator (postorder)" << endl;
UsePostorderIterator(container);
return 0;
}
@@ -0,0 +1,28 @@
#--------------------------------------------------------------------------#
# #
# MAKEFILE for Binary Search Tree examples #
# #
# Copyright (c) 1994 Borland International #
# All Rights Reserved #
# #
# Usage: #
# #
# make -DCON32 for 32-bit Windows Console #
# make MODEL={s|m|c|l} for 16-bit Windows using EasyWin #
# make MODEL={s|m|c|l|h} -DDOS16 for 16-bit DOS #
# #
#--------------------------------------------------------------------------#
EXE = bintree
EXEALL = bintree.exe ibintree.exe
EXEMAKE= $(BINTREE) $(IBINTREE)
RULES = myclass.obj: ..\myclass.cpp
BINTREE=$(EXERULE:bintree.obj=bintree.obj myclass.obj)
IBINTREE=$(BINTREE:bintree=ibintree)
!include $(BCEXAMPLEDIR)\bidsmake.gen
@@ -0,0 +1,40 @@
// ---------------------------------------------------------------------------
// Copyright (C) 1994 Borland International
// date.cpp
// ---------------------------------------------------------------------------
#include <classlib/date.h>
#include <iostream.h>
void PrintDate(TDate& date)
{
cout << date.NameOfDay() << " ";
cout << date.NameOfMonth() << " ";
cout << date.DayOfMonth() << ", " << date.Year();
}
int main()
{
TDate date;
cout << "Welcome to TDate!" << endl << endl;
cout << "Please enter the date you were born (MM/DD/YY): ";
cin >> date;
cout << "You were born on ";
PrintDate(date);
cout << "." << endl;
cout << "With 'operator <<', the date is " << date << endl << endl;
cout << "The year " << date.Year() << " was";
cout << (date.Leap() ? "" : " not") << " a leap year." << endl;
cout << "The week before that date was ";
PrintDate(date-7);
cout << "." << endl;
cout << "The week after that date was " << (date+7) << endl;
return 0;
}
@@ -0,0 +1,19 @@
#--------------------------------------------------------------------------#
# #
# MAKEFILE for DATE example #
# #
# Copyright (c) 1994 Borland International #
# All Rights Reserved #
# #
# Usage: #
# #
# make -DCON32 for 32-bit Windows Console #
# make MODEL={s|m|c|l} for 16-bit Windows using EasyWin #
# make MODEL={s|m|c|l|h} -DDOS16 for 16-bit DOS #
# #
#--------------------------------------------------------------------------#
EXE = datex
!include $(BCEXAMPLEDIR)\bidsmake.gen
@@ -0,0 +1,58 @@
// ---------------------------------------------------------------------------
// Copyright (C) 1994 Borland International
// deqlist.cpp
// Must link with myclass.cpp.
// ---------------------------------------------------------------------------
#include <classlib/deques.h>
#include <iostream.h>
#include <strstrea.h>
#include "../myclass.h"
typedef TDequeAsDoubleList<MyClass> ContainerType;
typedef TDequeAsDoubleListIterator<MyClass> IteratorType;
const int MaxItems=6;
void ForEachCallBack(MyClass& mc, void* s)
{
cout << (char*)s << mc << endl;
}
void AddItems(ContainerType& container, int numItems)
{
for( int i=numItems; i>0; i-- )
{
char buf[80];
ostrstream str( buf, sizeof(buf) );
str << i << " hello" << ends;
if( i % 2 == 0 )
container.PutLeft(MyClass(buf));
else
container.PutRight(MyClass(buf));
}
}
void UseForwardIterator(ContainerType& container)
{
IteratorType iterator(container);
while( iterator )
{
cout << iterator.Current() << endl;
iterator++;
}
}
int main()
{
ContainerType container;
AddItems(container, MaxItems);
cout << "--- Starting ForEach" << endl;
container.ForEach(ForEachCallBack, (void*)"FE ");
cout << "--- Starting Iterator" << endl;
UseForwardIterator(container);
return 0;
}
@@ -0,0 +1,58 @@
// ---------------------------------------------------------------------------
// Copyright (C) 1994 Borland International
// deque.cpp
// Must link with myclass.cpp.
// ---------------------------------------------------------------------------
#include <classlib/deques.h>
#include <iostream.h>
#include <strstrea.h>
#include "../myclass.h"
typedef TDequeAsVector<MyClass> ContainerType;
typedef TDequeAsVectorIterator<MyClass> IteratorType;
const int MaxItems=6;
void ForEachCallBack(MyClass& mc, void* s)
{
cout << (char*)s << mc << endl;
}
void AddItems(ContainerType& container, int numItems)
{
for( int i=numItems; i>0; i-- )
{
char buf[80];
ostrstream str(buf, sizeof(buf) );
str << i << " hello" << ends;
if( i % 2 == 0 )
container.PutLeft(MyClass(buf));
else
container.PutRight(MyClass(buf));
}
}
void UseForwardIterator(ContainerType& container)
{
IteratorType iterator(container);
while (iterator)
{
cout << iterator.Current() << endl;
iterator++;
}
}
int main()
{
ContainerType container;
AddItems(container, MaxItems);
cout << "--- Starting ForEach" << endl;
container.ForEach(ForEachCallBack, (void*)"FE ");
cout << "--- Starting Iterator" << endl;
UseForwardIterator(container);
return 0;
}
@@ -0,0 +1,58 @@
// ---------------------------------------------------------------------------
// Copyright (C) 1994 Borland International
// ideqlist.cpp
// Must link with myclass.cpp.
// ---------------------------------------------------------------------------
#include <classlib/deques.h>
#include <iostream.h>
#include <strstrea.h>
#include "../myclass.h"
typedef TIDequeAsDoubleList<MyClass> ContainerType;
typedef TIDequeAsDoubleListIterator<MyClass> IteratorType;
const int MaxItems=6;
void ForEachCallBack(MyClass& mc, void* s)
{
cout << (char*)s << mc << endl;
}
void AddItems(ContainerType& container, int numItems)
{
for( int i=numItems; i>0; i-- )
{
char buf[80];
ostrstream str( buf, sizeof(buf) );
str << i << " hello" << ends;
if( i % 2 == 0 )
container.PutLeft( new MyClass(buf) );
else
container.PutRight( new MyClass(buf) );
}
}
void UseForwardIterator(ContainerType& container)
{
IteratorType iterator(container);
while( iterator )
{
cout << *iterator.Current() << endl;
iterator++;
}
}
int main()
{
ContainerType container;
AddItems(container, MaxItems);
cout << "--- Starting ForEach" << endl;
container.ForEach(ForEachCallBack, (void*)"FE ");
cout << "--- Starting Iterator" << endl;
UseForwardIterator(container);
return 0;
}
@@ -0,0 +1,58 @@
// ---------------------------------------------------------------------------
// Copyright (C) 1994 Borland International
// ideque.cpp
// Must link with myclass.cpp.
// ---------------------------------------------------------------------------
#include <classlib/deques.h>
#include <iostream.h>
#include <strstrea.h>
#include "../myclass.h"
typedef TIDequeAsVector<MyClass> ContainerType;
typedef TIDequeAsVectorIterator<MyClass> IteratorType;
const int MaxItems=6;
void ForEachCallBack(MyClass& mc, void* s)
{
cout << (char*)s << mc << endl;
}
void AddItems(ContainerType& container, int numItems)
{
for( int i=numItems; i>0; i-- )
{
char buf[80];
ostrstream str( buf, sizeof(buf) );
str << i << " hello" << ends;
if( i % 2 == 0 )
container.PutLeft( new MyClass(buf) );
else
container.PutRight( new MyClass(buf) );
}
}
void UseForwardIterator(ContainerType& container)
{
IteratorType iterator(container);
while( iterator )
{
cout << *iterator.Current() << endl;
iterator++;
}
}
int main()
{
ContainerType container;
AddItems(container, MaxItems);
cout << "--- Starting ForEach" << endl;
container.ForEach(ForEachCallBack, (void*)"FE ");
cout << "--- Starting Iterator" << endl;
UseForwardIterator(container);
return 0;
}
@@ -0,0 +1,30 @@
#--------------------------------------------------------------------------#
# #
# MAKEFILE for Deque examples #
# #
# Copyright (c) 1994 Borland International #
# All Rights Reserved #
# #
# Usage: #
# #
# make -DCON32 for 32-bit Windows Console #
# make MODEL={s|m|c|l} for 16-bit Windows using EasyWin #
# make MODEL={s|m|c|l|h} -DDOS16 for 16-bit DOS #
# #
#--------------------------------------------------------------------------#
EXE = deque
EXEALL = deque.exe ideque.exe deqlist.exe ideqlist.exe
EXEMAKE= $(DEQUE) $(IDEQUE) $(DEQLIST) $(IDEQLIST)
RULES = myclass.obj: ..\myclass.cpp
DEQUE=$(EXERULE:deque.obj=deque.obj myclass.obj)
IDEQUE=$(DEQUE:deque=ideque)
DEQLIST=$(DEQUE:deque=deqlist)
IDEQLIST=$(DEQUE:deque=ideqlist)
!include $(BCEXAMPLEDIR)\bidsmake.gen
@@ -0,0 +1,55 @@
// ---------------------------------------------------------------------------
// Copyright (C) 1994 Borland International
// hash.cpp
// Must link with myclass.cpp.
// ---------------------------------------------------------------------------
#include <classlib/hashimp.h>
#include <iostream.h>
#include <strstrea.h>
#include "../myclass.h"
typedef THashTableImp<MyClass> ContainerType;
typedef THashTableIteratorImp<MyClass> IteratorType;
const int MaxItems=6;
void ForEachCallBack(MyClass& mc, void* s)
{
cout << (char*)s << mc << endl;
}
void AddItems(ContainerType& container, int numItems)
{
for( int i=numItems; i>0; i-- )
{
char buf[80];
ostrstream str( buf, sizeof(buf) );
str << i << " hello" << ends;
container.Add(MyClass(buf));
}
}
void UseForwardIterator(ContainerType& container)
{
IteratorType iterator(container);
while( iterator )
{
cout << iterator.Current() << endl;
iterator++;
}
}
int main()
{
ContainerType container;
AddItems(container, MaxItems);
cout << "--- Starting ForEach" << endl;
container.ForEach(ForEachCallBack, (void*)"FE ");
cout << "--- Starting Iterator (forward)" << endl;
UseForwardIterator(container);
return 0;
}
@@ -0,0 +1,55 @@
// ---------------------------------------------------------------------------
// Copyright (C) 1994 Borland International
// ihash.cpp
// Must link with myclass.cpp.
// ---------------------------------------------------------------------------
#include <classlib/hashimp.h>
#include <iostream.h>
#include <strstrea.h>
#include "../myclass.h"
typedef TIHashTableImp<MyClass> ContainerType;
typedef TIHashTableIteratorImp<MyClass> IteratorType;
const int MaxItems=6;
void ForEachCallBack(MyClass& mc, void* s)
{
cout << (char*)s << mc << endl;
}
void AddItems(ContainerType& container, int numItems)
{
for( int i=numItems; i>0; i-- )
{
char buf[80];
ostrstream str( buf, sizeof(buf) );
str << i << " hello" << ends;
container.Add( new MyClass(buf) );
}
}
void UseForwardIterator(ContainerType& container)
{
IteratorType iterator(container);
while( iterator )
{
cout << *iterator.Current() << endl;
iterator++;
}
}
int main()
{
ContainerType container;
AddItems(container, MaxItems);
cout << "--- Starting ForEach" << endl;
container.ForEach(ForEachCallBack, (void*)"FE ");
cout << "--- Starting Iterator (forward)" << endl;
UseForwardIterator(container);
return 0;
}
@@ -0,0 +1,28 @@
#--------------------------------------------------------------------------#
# #
# MAKEFILE for Hash Table examples #
# #
# Copyright (c) 1994 Borland International #
# All Rights Reserved #
# #
# Usage: #
# #
# make -DCON32 for 32-bit Windows Console #
# make MODEL={s|m|c|l} for 16-bit Windows using EasyWin #
# make MODEL={s|m|c|l|h} -DDOS16 for 16-bit DOS #
# #
#--------------------------------------------------------------------------#
EXE = hash
EXEALL = hash.exe ihash.exe
EXEMAKE= $(HASH) $(IHASH)
RULES = myclass.obj: ..\myclass.cpp
HASH=$(EXERULE:hash.obj=hash.obj myclass.obj)
IHASH=$(HASH:hash=ihash)
!include $(BCEXAMPLEDIR)\bidsmake.gen
@@ -0,0 +1,76 @@
// ---------------------------------------------------------------------------
// Copyright (C) 1994 Borland International
// dlist.cpp
// Must link with myclass.cpp.
// ---------------------------------------------------------------------------
#include <classlib/dlistimp.h>
#include <iostream.h>
#include <strstrea.h>
#include "../myclass.h"
typedef TDoubleListImp<MyClass> ContainerType;
typedef TDoubleListIteratorImp<MyClass> IteratorType;
const int MaxItems=6;
void ForEachCallBack(MyClass& mc, void* s)
{
cout << (char*)s << mc << endl;
}
void AddItems(ContainerType& container, int numItems)
{
for( int i=numItems; i>0; i-- )
{
char buf[80];
ostrstream str( buf, sizeof(buf) );
str << i << " hello" << ends;
if (i%2 == 0)
container.Add(MyClass(buf)); // defaults to adding at head
else
container.AddAtTail(MyClass(buf));
}
}
void UseForwardIterator(ContainerType& container)
{
IteratorType iterator(container);
while( iterator )
{
cout << iterator.Current() << endl;
iterator++;
}
}
void UseBackwardIterator(ContainerType& container)
{
IteratorType iterator(container);
iterator.RestartAtTail();
while( iterator )
{
cout << iterator.Current() << endl;
iterator--;
}
}
int main()
{
ContainerType container;
AddItems(container, MaxItems);
cout << "--- Starting ForEach" << endl;
container.ForEach(ForEachCallBack, (void*)"FE ");
cout << "--- Starting Iterator (forward)" << endl;
UseForwardIterator(container);
cout << "--- Deleting '3 hello'" << endl;
container.Detach(MyClass("3 hello")); // detach and delete
cout << "--- Starting Iterator (backward)" << endl;
UseBackwardIterator(container);
return 0;
}
@@ -0,0 +1,78 @@
// ---------------------------------------------------------------------------
// Copyright (C) 1994 Borland International
// idlist.cpp
// Must link with myclass.cpp.
// ---------------------------------------------------------------------------
#include <classlib/dlistimp.h>
#include <iostream.h>
#include <strstrea.h>
#include "../myclass.h"
typedef TIDoubleListImp<MyClass> ContainerType;
typedef TIDoubleListIteratorImp<MyClass> IteratorType;
const int MaxItems=6;
void ForEachCallBack(MyClass& mc, void* s)
{
cout << (char*)s << mc << endl;
}
void AddItems(ContainerType& container, int numItems)
{
for( int i=numItems; i>0; i-- )
{
char buf[80];
ostrstream str( buf, sizeof(buf) );
str << i << " hello" << ends;
if( i%2 == 0 )
container.Add( new MyClass(buf) );
else
container.AddAtTail( new MyClass(buf) );
}
}
void UseForwardIterator(ContainerType& container)
{
IteratorType iterator(container);
while( iterator )
{
cout << *iterator.Current() << endl;
iterator++;
}
}
void UseBackwardIterator(ContainerType& container)
{
IteratorType iterator(container);
iterator.RestartAtTail();
while( iterator )
{
cout << *iterator.Current() << endl;
iterator--;
}
}
int main()
{
ContainerType container;
AddItems(container, MaxItems);
cout << "--- Starting ForEach" << endl;
container.ForEach(ForEachCallBack, (void*)"FE ");
cout << "--- Starting Iterator (forward)" << endl;
UseForwardIterator(container);
MyClass test("3 hello");
cout << "--- Deleting '" << test << "'" << endl;
container.Detach(&test); // detach and delete
cout << endl;
cout << "--- Starting Iterator (backward)" << endl;
UseBackwardIterator(container);
return 0;
}
@@ -0,0 +1,59 @@
// ---------------------------------------------------------------------------
// Copyright (C) 1994 Borland International
// ilist.cpp
// Must link with myclass.cpp.
// ---------------------------------------------------------------------------
#include <classlib/listimp.h>
#include <iostream.h>
#include <strstrea.h>
#include "../myclass.h"
typedef TIListImp<MyClass> ContainerType;
typedef TIListIteratorImp<MyClass> IteratorType;
const int MaxItems=6;
void ForEachCallBack(MyClass& mc, void* s)
{
cout << (char*)s << mc << endl;
}
void AddItems(ContainerType& container, int numItems)
{
for( int i=numItems; i>0; i-- )
{
char buf[80];
ostrstream str( buf, sizeof(buf) );
str << i << " hello" << ends;
container.Add( new MyClass(buf) );
}
}
void UseForwardIterator(ContainerType& container)
{
IteratorType iterator(container);
while( iterator )
{
cout << *iterator.Current() << endl;
iterator++;
}
}
int main()
{
ContainerType container;
AddItems(container, MaxItems);
cout << "--- Starting ForEach" << endl;
container.ForEach(ForEachCallBack, (void*)"FE ");
cout << "--- Detaching at head" << endl;
container.DetachAtHead();
cout << "--- Starting Iterator (forward)" << endl;
UseForwardIterator(container);
return 0;
}
@@ -0,0 +1,75 @@
// ---------------------------------------------------------------------------
// Copyright (C) 1994 Borland International
// isdlist.cpp
// Must link with myclass.cpp.
// ---------------------------------------------------------------------------
#include <classlib/dlistimp.h>
#include <iostream.h>
#include <strstrea.h>
#include "../myclass.h"
typedef TISDoubleListImp<MyClass> ContainerType;
typedef TISDoubleListIteratorImp<MyClass> IteratorType;
const int MaxItems=6;
void ForEachCallBack(MyClass& mc, void* s)
{
cout << (char*)s << mc << endl;
}
void AddItems(ContainerType& container, int numItems)
{
for( int i=numItems; i>0; i-- )
{
char buf[80];
ostrstream str( buf, sizeof(buf) );
str << i << " hello" << ends;
container.Add( new MyClass(buf) );
}
}
void UseForwardIterator(ContainerType& container)
{
IteratorType iterator(container);
while( iterator )
{
cout << *iterator.Current() << endl;
iterator++;
}
}
void UseBackwardIterator(ContainerType& container)
{
IteratorType iterator(container);
iterator.RestartAtTail();
while( iterator )
{
cout << *iterator.Current() << endl;
iterator--;
}
}
int main()
{
ContainerType container;
AddItems(container, MaxItems);
cout << "--- Starting ForEach" << endl;
container.ForEach(ForEachCallBack, (void*)"FE ");
cout << "--- Starting Iterator (forward)" << endl;
UseForwardIterator(container);
MyClass test("3 hello");
cout << "--- Deleting '" << test << "'" << endl;
container.Detach(&test); // detach and delete
cout << endl;
cout << "--- Starting Iterator (backward)" << endl;
UseBackwardIterator(container);
return 0;
}
@@ -0,0 +1,55 @@
// ---------------------------------------------------------------------------
// Copyright (C) 1994 Borland International
// islist.cpp
// Must link with myclass.cpp.
// ---------------------------------------------------------------------------
#include <classlib/listimp.h>
#include <iostream.h>
#include <strstrea.h>
#include "../myclass.h"
typedef TISListImp<MyClass> ContainerType;
typedef TISListIteratorImp<MyClass> IteratorType;
const int MaxItems=6;
void ForEachCallBack(MyClass& mc, void* s)
{
cout << (char*)s << mc << endl;
}
void AddItems(ContainerType& container, int numItems)
{
for( int i=numItems; i>0; i-- )
{
char buf[80];
ostrstream str( buf, sizeof(buf) );
str << i << " hello" << ends;
container.Add( new MyClass(buf) );
}
}
void UseForwardIterator(ContainerType& container)
{
IteratorType iterator(container);
while( iterator )
{
cout << *iterator.Current() << endl;
iterator++;
}
}
int main()
{
ContainerType container;
AddItems(container, MaxItems);
cout << "--- Starting ForEach" << endl;
container.ForEach(ForEachCallBack, (void*)"FE ");
cout << "--- Starting Iterator (forward)" << endl;
UseForwardIterator(container);
return 0;
}
@@ -0,0 +1,55 @@
// ---------------------------------------------------------------------------
// Copyright (C) 1994 Borland International
// list.cpp
// Must link with myclass.cpp.
// ---------------------------------------------------------------------------
#include <classlib/listimp.h>
#include <iostream.h>
#include <strstrea.h>
#include "../myclass.h"
typedef TListImp<MyClass> ContainerType;
typedef TListIteratorImp<MyClass> IteratorType;
const int MaxItems=6;
void ForEachCallBack(MyClass& mc, void* s)
{
cout << (char*)s << mc << endl;
}
void AddItems(ContainerType& container, int numItems)
{
for( int i=numItems; i>0; i-- )
{
char buf[80];
ostrstream str( buf, sizeof(buf) );
str << i << " hello" << ends;
container.Add( MyClass(buf) );
}
}
void UseForwardIterator(ContainerType& container)
{
IteratorType iterator(container);
while( iterator )
{
cout << iterator.Current() << endl;
iterator++;
}
}
int main()
{
ContainerType container;
AddItems(container, MaxItems);
cout << "--- Starting ForEach" << endl;
container.ForEach(ForEachCallBack, (void*)"FE ");
cout << "--- Starting Iterator (forward)" << endl;
UseForwardIterator(container);
return 0;
}
@@ -0,0 +1,36 @@
#--------------------------------------------------------------------------#
# #
# MAKEFILE for List examples #
# #
# Copyright (c) 1994 Borland International #
# All Rights Reserved #
# #
# Usage: #
# #
# make -DCON32 for 32-bit Windows Console #
# make MODEL={s|m|c|l} for 16-bit Windows using EasyWin #
# make MODEL={s|m|c|l|h} -DDOS16 for 16-bit DOS #
# #
#--------------------------------------------------------------------------#
EXE = listx
EXEALL = listx.exe ilist.exe slist.exe islist.exe \
dlist.exe idlist.exe sdlist.exe isdlist.exe
EXEMAKE= $(LIST) $(ILIST) $(SLIST) $(ISLIST) \
$(DLIST) $(IDLIST) $(SDLIST) $(ISDLIST)
RULES = myclass.obj: ..\myclass.cpp
LIST=$(EXERULE:listx.obj=listx.obj myclass.obj)
ILIST=$(LIST:listx=ilist)
SLIST=$(LIST:listx=slist)
ISLIST=$(LIST:listx=islist)
DLIST=$(LIST:listx=dlist)
IDLIST=$(LIST:listx=idlist)
SDLIST=$(LIST:listx=sdlist)
ISDLIST=$(LIST:listx=isdlist)
!include $(BCEXAMPLEDIR)\bidsmake.gen
@@ -0,0 +1,74 @@
// ---------------------------------------------------------------------------
// Copyright (C) 1994 Borland International
// sdlist.cpp
// Must link with myclass.cpp.
// ---------------------------------------------------------------------------
#include <classlib/dlistimp.h>
#include <iostream.h>
#include <strstrea.h>
#include "../myclass.h"
typedef TSDoubleListImp<MyClass> ContainerType;
typedef TSDoubleListIteratorImp<MyClass> IteratorType;
const int MaxItems=6;
void ForEachCallBack(MyClass& mc, void* s)
{
cout << (char*)s << mc << endl;
}
void AddItems(ContainerType& container, int numItems)
{
for( int i=numItems; i>0; i-- )
{
char buf[80];
ostrstream str( buf, sizeof(buf) );
str << i << " hello" << ends;
MyClass tempItem(buf);
container.Add(tempItem);
}
}
void UseForwardIterator(ContainerType& container)
{
IteratorType iterator(container);
while( iterator )
{
cout << iterator.Current() << endl;
iterator++;
}
}
void UseBackwardIterator(ContainerType& container)
{
IteratorType iterator(container);
iterator.RestartAtTail();
while( iterator )
{
cout << iterator.Current() << endl;
iterator--;
}
}
int main()
{
ContainerType container;
AddItems(container, MaxItems);
cout << "--- Starting ForEach" << endl;
container.ForEach(ForEachCallBack, (void*)"FE ");
cout << "--- Starting Iterator (forward)" << endl;
UseForwardIterator(container);
cout << "--- Deleting '3 hello'" << endl;
container.Detach(MyClass("3 hello")); // detach and delete
cout << "--- Starting Iterator (backward)" << endl;
UseBackwardIterator(container);
return 0;
}
@@ -0,0 +1,55 @@
// ---------------------------------------------------------------------------
// Copyright (C) 1994 Borland International
// slist.cpp
// Must link with myclass.cpp.
// ---------------------------------------------------------------------------
#include <classlib/listimp.h>
#include <iostream.h>
#include <strstrea.h>
#include "../myclass.h"
typedef TSListImp<MyClass> ContainerType;
typedef TSListIteratorImp<MyClass> IteratorType;
const int MaxItems=6;
void ForEachCallBack(MyClass& mc, void* s)
{
cout << (char*)s << mc << endl;
}
void AddItems(ContainerType& container, int numItems)
{
for( int i=numItems; i>0; i-- )
{
char buf[80];
ostrstream str( buf, sizeof(buf) );
str << i << " hello" << ends;
container.Add(MyClass(buf));
}
}
void UseForwardIterator(ContainerType& container)
{
IteratorType iterator(container);
while( iterator )
{
cout << iterator.Current() << endl;
iterator++;
}
}
int main()
{
ContainerType container;
AddItems(container, MaxItems);
cout << "--- Starting ForEach" << endl;
container.ForEach(ForEachCallBack, (void*)"FE ");
cout << "--- Starting Iterator (forward)" << endl;
UseForwardIterator(container);
return 0;
}
@@ -0,0 +1,107 @@
// ---------------------------------------------------------------------------
// Copyright (C) 1994 Borland International
// myclass.cpp
// ---------------------------------------------------------------------------
#include "..\myclass.h"
MyClass::MyClass()
{
TRACE("Empty MyClass");
}
MyClass::MyClass(const string& s)
: Str(s)
{
TRACE("Con string '" << Str << "'");
}
MyClass::MyClass(const MyClass& mc)
: Str(mc.Str)
{
TRACE("Copy string '" << Str << "'");
}
MyClass::~MyClass()
{
TRACE("Des string '" << Str << "'");
}
MyClass& MyClass::operator=(const MyClass& mc)
{
Str = mc.Str;
return *this;
}
int MyClass::operator==(const MyClass& mc) const
{
return Str == mc.Str;
}
int MyClass::operator<(const MyClass& mc) const
{
return Str < mc.Str;
}
unsigned MyClass::HashValue() const
{
return Str.hash();
}
ostream& operator<<(ostream& os, const MyClass mc)
{
return os << "'" << mc.Str << "' hash = " << mc.HashValue();
}
//
// MyValue
//
MyValue::MyValue()
{
TRACE("Empty MyValue");
}
MyValue::MyValue(const string& s)
: Str(s)
{
TRACE("Con string '" << Str << "'");
}
MyValue::MyValue(const MyValue& mv)
: Str(mv.Str)
{
TRACE("Copy string '" << Str << "'");
}
MyValue::~MyValue()
{
TRACE("Des string '" << Str << "'");
}
MyValue& MyValue::operator=(const MyValue& mv)
{
Str = mv.Str;
return *this;
}
int MyValue::operator==(const MyValue& mv) const
{
return Str == mv.Str;
}
int MyValue::operator<(const MyValue& mv) const
{
return Str < mv.Str;
}
unsigned MyValue::HashValue() const
{
return Str.hash();
}
ostream& operator<<(ostream& os, const MyValue mv)
{
return os << "'" << mv.Str << "' hash = " << mv.HashValue();
}
@@ -0,0 +1,71 @@
// ---------------------------------------------------------------------------
// Copyright (C) 1994 Borland International
// myclass.h
//
// Description:
// This header file is provided to demonstrate the container
// class libraries.
// This implements the user-defined class.
// It defines the following member functions:
// (required for the direct containers)
// - Copy constructor
// - Assignment operator
// - comparison operators ( ==, < )
// - HashValue (only needed for the HashTable containers)
//
// Define DEBUG to see when the constructors and destructors
// are called. This is useful to track down memory leaks.
// ---------------------------------------------------------------------------
#ifndef MYCLASS_H // prevent header from
#define MYCLASS_H 1 // being included twice
#include <cstring.h>
#include <iostream.h>
#include <checks.h>
class MyClass
{
public:
MyClass();
MyClass(const string& s);
MyClass(const MyClass& mc);
~MyClass();
MyClass& operator=(const MyClass& mc);
int operator==(const MyClass& mc) const;
int operator<(const MyClass& mc) const;
unsigned HashValue() const;
friend ostream& operator << (ostream&, const MyClass);
private:
string Str;
};
//
// MyValue is to be used with TAssociation or TDictionary.
//
class MyValue
{
public:
MyValue();
MyValue(const string& s);
MyValue(const MyValue& mv);
~MyValue();
MyValue& operator=(const MyValue& mv);
int operator==(const MyValue& mv) const;
int operator<(const MyValue& mv) const;
unsigned HashValue() const;
friend ostream& operator << (ostream&, const MyValue);
private:
string Str;
};
#endif
@@ -0,0 +1,55 @@
// ---------------------------------------------------------------------------
// Copyright (C) 1994 Borland International
// iquelist.cpp
// Must link with myclass.cpp.
// ---------------------------------------------------------------------------
#include <classlib/queues.h>
#include <iostream.h>
#include <strstrea.h>
#include "../myclass.h"
typedef TIQueueAsDoubleList<MyClass> ContainerType;
typedef TIQueueAsDoubleListIterator<MyClass> IteratorType;
const int MaxItems=6;
void ForEachCallBack(MyClass& mc, void* s)
{
cout << (char*)s << mc << endl;
}
void AddItems(ContainerType& container, int numItems)
{
for( int i=numItems; i>0; i-- )
{
char buf[80];
ostrstream str( buf, sizeof(buf) );
str << i << " hello" << ends;
container.Put( new MyClass(buf) );
}
}
void UseForwardIterator(ContainerType& container)
{
IteratorType iterator(container);
while( iterator )
{
cout << *iterator.Current() << endl;
iterator++;
}
}
int main()
{
ContainerType container;
AddItems(container, MaxItems);
cout << "--- Starting ForEach" << endl;
container.ForEach(ForEachCallBack, (void*)"FE ");
cout << "--- Starting Iterator" << endl;
UseForwardIterator(container);
return 0;
}
@@ -0,0 +1,55 @@
// ---------------------------------------------------------------------------
// Copyright (C) 1994 Borland International
// iqueue.cpp
// Must link with myclass.cpp.
// ---------------------------------------------------------------------------
#include <classlib/queues.h>
#include <iostream.h>
#include <strstrea.h>
#include "../myclass.h"
typedef TIQueueAsDoubleList<MyClass> ContainerType;
typedef TIQueueAsDoubleListIterator<MyClass> IteratorType;
const int MaxItems=6;
void ForEachCallBack(MyClass& mc, void* s)
{
cout << (char*)s << mc << endl;
}
void AddItems(ContainerType& container, int numItems)
{
for( int i=numItems; i>0; i-- )
{
char buf[80];
ostrstream str( buf, sizeof(buf) );
str << i << " hello" << ends;
container.Put( new MyClass(buf) );
}
}
void UseForwardIterator(ContainerType& container)
{
IteratorType iterator(container);
while( iterator )
{
cout << *iterator.Current() << endl;
iterator++;
}
}
int main()
{
ContainerType container;
AddItems(container, MaxItems);
cout << "--- Starting ForEach" << endl;
container.ForEach(ForEachCallBack, (void*)"FE ");
cout << "--- Starting Iterator" << endl;
UseForwardIterator(container);
return 0;
}
@@ -0,0 +1,30 @@
#--------------------------------------------------------------------------#
# #
# MAKEFILE for QUEUE examples #
# #
# Copyright (c) 1994 Borland International #
# All Rights Reserved #
# #
# Usage: #
# #
# make -DCON32 for 32-bit Windows Console #
# make MODEL={s|m|c|l} for 16-bit Windows using EasyWin #
# make MODEL={s|m|c|l|h} -DDOS16 for 16-bit DOS #
# #
#--------------------------------------------------------------------------#
EXE = queue
EXEALL = queue.exe iqueue.exe quelist.exe iquelist.exe
EXEMAKE= $(QUEUE) $(IQUEUE) $(QUELIST) $(IQUELIST)
RULES = myclass.obj: ..\myclass.cpp
QUEUE=$(EXERULE:queue.obj=queue.obj myclass.obj)
IQUEUE=$(QUEUE:queue=iqueue)
QUELIST=$(QUEUE:queue=quelist)
IQUELIST=$(QUEUE:queue=iquelist)
!include $(BCEXAMPLEDIR)\bidsmake.gen
@@ -0,0 +1,55 @@
// ---------------------------------------------------------------------------
// Copyright (C) 1994 Borland International
// quelist.cpp
// Must link with myclass.cpp.
// ---------------------------------------------------------------------------
#include <classlib/queues.h>
#include <iostream.h>
#include <strstrea.h>
#include "../myclass.h"
typedef TQueueAsDoubleList<MyClass> ContainerType;
typedef TQueueAsDoubleListIterator<MyClass> IteratorType;
const int MaxItems=6;
void ForEachCallBack(MyClass& mc, void* s)
{
cout << (char*)s << mc << endl;
}
void AddItems(ContainerType& container, int numItems)
{
for( int i=numItems; i>0; i-- )
{
char buf[80];
ostrstream str( buf, sizeof(buf) );
str << i << " hello" << ends;
container.Put( MyClass(buf) );
}
}
void UseForwardIterator(ContainerType& container)
{
IteratorType iterator(container);
while( iterator )
{
cout << iterator.Current() << endl;
iterator++;
}
}
int main()
{
ContainerType container;
AddItems(container, MaxItems);
cout << "--- Starting ForEach" << endl;
container.ForEach(ForEachCallBack, (void*)"FE ");
cout << "--- Starting Iterator" << endl;
UseForwardIterator(container);
return 0;
}
@@ -0,0 +1,55 @@
// ---------------------------------------------------------------------------
// Copyright (C) 1994 Borland International
// queue.cpp
// Must link with myclass.cpp.
// ---------------------------------------------------------------------------
#include <classlib/queues.h>
#include <iostream.h>
#include <strstrea.h>
#include "../myclass.h"
typedef TQueueAsVector<MyClass> ContainerType;
typedef TQueueAsVectorIterator<MyClass> IteratorType;
const int MaxItems=6;
void ForEachCallBack(MyClass& mc, void* s)
{
cout << (char*)s << mc << endl;
}
void AddItems(ContainerType& container, int numItems)
{
for( int i=numItems; i>0; i-- )
{
char buf[80];
ostrstream str( buf, sizeof(buf) );
str << i << " hello" << ends;
container.Put( MyClass(buf) );
}
}
void UseForwardIterator(ContainerType& container)
{
IteratorType iterator(container);
while( iterator )
{
cout << iterator.Current() << endl;
iterator++;
}
}
int main()
{
ContainerType container;
AddItems(container, MaxItems);
cout << "--- Starting ForEach" << endl;
container.ForEach(ForEachCallBack, (void*)"FE ");
cout << "--- Starting Iterator" << endl;
UseForwardIterator(container);
return 0;
}
@@ -0,0 +1,55 @@
// ---------------------------------------------------------------------------
// Copyright (C) 1994 Borland International
// iset.cpp
// Must link with myclass.cpp.
// ---------------------------------------------------------------------------
#include <classlib/sets.h>
#include <iostream.h>
#include <strstrea.h>
#include "../myclass.h"
typedef TISetAsVector<MyClass> ContainerType;
typedef TISetAsVectorIterator<MyClass> IteratorType;
const int MaxItems=6;
void ForEachCallBack(MyClass& mc, void* s)
{
cout << (char*)s << mc << endl;
}
void AddItems(ContainerType& container, int numItems)
{
for( int i=numItems; i>0; i-- )
{
char buf[80];
ostrstream str( buf, sizeof(buf) );
str << i << " hello" << ends;
container.Add( new MyClass(buf) );
}
}
void UseForwardIterator(ContainerType& container)
{
IteratorType iterator(container);
while( iterator )
{
cout << *iterator.Current() << endl;
iterator++;
}
}
int main()
{
ContainerType container(MaxItems);
AddItems(container, MaxItems);
cout << "--- Starting ForEach" << endl;
container.ForEach(ForEachCallBack, (void*)"FE ");
cout << "--- Starting Iterator (forward)" << endl;
UseForwardIterator(container);
return 0;
}
Binary file not shown.
@@ -0,0 +1,28 @@
#--------------------------------------------------------------------------#
# #
# MAKEFILE for Set examples #
# #
# Copyright (c) 1994 Borland International #
# All Rights Reserved #
# #
# Usage: #
# #
# make -DCON32 for 32-bit Windows Console #
# make MODEL={s|m|c|l} for 16-bit Windows using EasyWin #
# make MODEL={s|m|c|l|h} -DDOS16 for 16-bit DOS #
# #
#--------------------------------------------------------------------------#
EXE = setx
EXEALL = setx.exe iset.exe
EXEMAKE= $(SET) $(ISET)
RULES = myclass.obj: ..\myclass.cpp
SET=$(EXERULE:setx.obj=setx.obj myclass.obj)
ISET=$(SET:setx=iset)
!include $(BCEXAMPLEDIR)\bidsmake.gen
Binary file not shown.
@@ -0,0 +1,55 @@
// ---------------------------------------------------------------------------
// Copyright (C) 1994 Borland International
// set.cpp
// Must link with myclass.cpp.
// ---------------------------------------------------------------------------
#include <classlib/sets.h>
#include <iostream.h>
#include <strstrea.h>
#include "../myclass.h"
typedef TSetAsVector<MyClass> ContainerType;
typedef TSetAsVectorIterator<MyClass> IteratorType;
const int MaxItems=6;
void ForEachCallBack(MyClass& mc, void* s)
{
cout << (char*)s << mc << endl;
}
void AddItems(ContainerType& container, int numItems)
{
for( int i=numItems; i>0; i-- )
{
char buf[80];
ostrstream str( buf, sizeof(buf) );
str << i << " hello" << ends;
container.Add(MyClass(buf));
}
}
void UseForwardIterator(ContainerType& container)
{
IteratorType iterator(container);
while( iterator )
{
cout << iterator.Current() << endl;
iterator++;
}
}
int main()
{
ContainerType container(MaxItems);
AddItems(container, MaxItems);
cout << "--- Starting ForEach" << endl;
container.ForEach(ForEachCallBack, (void*)"FE ");
cout << "--- Starting Iterator (forward)" << endl;
UseForwardIterator(container);
return 0;
}
Binary file not shown.
@@ -0,0 +1,55 @@
// ---------------------------------------------------------------------------
// Copyright (C) 1994 Borland International
// istack.cpp
// Must link with myclass.cpp.
// ---------------------------------------------------------------------------
#include <classlib/stacks.h>
#include <iostream.h>
#include <strstrea.h>
#include "../myclass.h"
typedef TIStackAsVector<MyClass> ContainerType;
typedef TIStackAsVectorIterator<MyClass> IteratorType;
const int MaxItems=6;
void ForEachCallBack(MyClass& mc, void* s)
{
cout << (char*)s << mc << endl;
}
void AddItems(ContainerType& container, int numItems)
{
for( int i=numItems; i>0; i-- )
{
char buf[80];
ostrstream str( buf, sizeof(buf) );
str << i << " hello" << ends;
container.Push( new MyClass(buf) );
}
}
void UseForwardIterator(ContainerType& container)
{
IteratorType iterator(container);
while( iterator )
{
cout << *iterator.Current() << endl;
iterator++;
}
}
int main()
{
ContainerType container;
AddItems(container, MaxItems);
cout << "--- Starting ForEach" << endl;
container.ForEach(ForEachCallBack, (void*)"FE ");
cout << "--- Starting Iterator" << endl;
UseForwardIterator(container);
return 0;
}
@@ -0,0 +1,55 @@
// ---------------------------------------------------------------------------
// Copyright (C) 1994 Borland International
// istklist.cpp
// Must link with myclass.cpp.
// ---------------------------------------------------------------------------
#include <classlib/stacks.h>
#include <iostream.h>
#include <strstrea.h>
#include "../myclass.h"
typedef TIStackAsList<MyClass> ContainerType;
typedef TIStackAsListIterator<MyClass> IteratorType;
const int MaxItems=6;
void ForEachCallBack(MyClass& mc, void* s)
{
cout << (char*)s << mc << endl;
}
void AddItems(ContainerType& container, int numItems)
{
for( int i=numItems; i>0; i-- )
{
char buf[80];
ostrstream str( buf, sizeof(buf) );
str << i << " hello" << ends;
container.Push( new MyClass(buf) );
}
}
void UseForwardIterator(ContainerType& container)
{
IteratorType iterator(container);
while( iterator )
{
cout << *iterator.Current() << endl;
iterator++;
}
}
int main()
{
ContainerType container;
AddItems(container, MaxItems);
cout << "--- Starting ForEach" << endl;
container.ForEach(ForEachCallBack, (void*)"FE ");
cout << "--- Starting Iterator" << endl;
UseForwardIterator(container);
return 0;
}
@@ -0,0 +1,30 @@
#--------------------------------------------------------------------------#
# #
# MAKEFILE for Stack examples #
# #
# Copyright (c) 1994 Borland International #
# All Rights Reserved #
# #
# Usage: #
# #
# make -DCON32 for 32-bit Windows Console #
# make MODEL={s|m|c|l} for 16-bit Windows using EasyWin #
# make MODEL={s|m|c|l|h} -DDOS16 for 16-bit DOS #
# #
#--------------------------------------------------------------------------#
EXE = stack
EXEALL = stack.exe istack.exe stklist.exe istklist.exe
EXEMAKE= $(STACK) $(ISTACK) $(STKLIST) $(ISTKLIST)
RULES = myclass.obj: ..\myclass.cpp
STACK=$(EXERULE:stack.obj=stack.obj myclass.obj)
ISTACK=$(STACK:stack=istack)
STKLIST=$(STACK:stack=stklist)
ISTKLIST=$(STACK:stack=istklist)
!include $(BCEXAMPLEDIR)\bidsmake.gen
@@ -0,0 +1,55 @@
// ---------------------------------------------------------------------------
// Copyright (C) 1994 Borland International
// stack.cpp
// Must link with myclass.cpp.
// ---------------------------------------------------------------------------
#include <classlib/stacks.h>
#include <iostream.h>
#include <strstrea.h>
#include "../myclass.h"
typedef TStackAsVector<MyClass> ContainerType;
typedef TStackAsVectorIterator<MyClass> IteratorType;
const int MaxItems=6;
void ForEachCallBack(MyClass& mc, void* s)
{
cout << (char*)s << mc << endl;
}
void AddItems(ContainerType& container, int numItems)
{
for( int i=numItems; i>0; i-- )
{
char buf[80];
ostrstream str( buf, sizeof(buf) );
str << i << " hello" << ends;
container.Push(MyClass(buf));
}
}
void UseForwardIterator(ContainerType& container)
{
IteratorType iterator(container);
while( iterator )
{
cout << iterator.Current() << endl;
iterator++;
}
}
int main()
{
ContainerType container;
AddItems(container, MaxItems);
cout << "--- Starting ForEach" << endl;
container.ForEach(ForEachCallBack, (void*)"FE ");
cout << "--- Starting Iterator" << endl;
UseForwardIterator(container);
return 0;
}
@@ -0,0 +1,55 @@
// ---------------------------------------------------------------------------
// Copyright (C) 1994 Borland International
// stklist.cpp
// Must link with myclass.cpp.
// ---------------------------------------------------------------------------
#include <classlib/stacks.h>
#include <iostream.h>
#include <strstrea.h>
#include "../myclass.h"
typedef TStackAsList<MyClass> ContainerType;
typedef TStackAsListIterator<MyClass> IteratorType;
const int MaxItems=6;
void ForEachCallBack(MyClass& mc, void* s)
{
cout << (char*)s << mc << endl;
}
void AddItems(ContainerType& container, int numItems)
{
for( int i=numItems; i>0; i-- )
{
char buf[80];
ostrstream str( buf, sizeof(buf) );
str << i << " hello" << ends;
container.Push(MyClass(buf));
}
}
void UseForwardIterator(ContainerType& container)
{
IteratorType iterator(container);
while( iterator )
{
cout << iterator.Current() << endl;
iterator++;
}
}
int main()
{
ContainerType container;
AddItems(container, MaxItems);
cout << "--- Starting ForEach" << endl;
container.ForEach(ForEachCallBack, (void*)"FE ");
cout << "--- Starting Iterator" << endl;
UseForwardIterator(container);
return 0;
}

Some files were not shown because too many files have changed in this diff Show More