[Avida-cvs] [Avida2-svn] r339 - in trunk: . Avida2.xcodeproj source/bindings/Boost.Python source/cpu source/event source/main source/testsuites/unit_testsuites source/tools source/utils/hist_map source/utils/task_events source/viewers
brysonda@myxo.css.msu.edu
brysonda at myxo.css.msu.edu
Mon Oct 10 17:04:45 PDT 2005
Author: brysonda
Date: 2005-10-10 19:44:52 -0400 (Mon, 10 Oct 2005)
New Revision: 339
Added:
trunk/source/tools/cTools.cc
trunk/source/tools/cTools.h
trunk/source/tools/cUInt.h
trunk/source/tools/cWeightedIndex.cc
trunk/source/tools/cWeightedIndex.h
trunk/source/tools/tArgDataEntry.h
trunk/source/tools/tArray.h
trunk/source/tools/tBuffer.h
trunk/source/tools/tDataEntry.h
trunk/source/tools/tDataEntryBase.h
trunk/source/tools/tDataEntryCommand.h
trunk/source/tools/tDataManager.h
trunk/source/tools/tDictionary.h
trunk/source/tools/tHashTable.h
trunk/source/tools/tList.h
trunk/source/tools/tMatrix.h
trunk/source/tools/tMemTrack.h
trunk/source/tools/tVector.h
Removed:
trunk/source/tools/tArgDataEntry.hh
trunk/source/tools/tArray.hh
trunk/source/tools/tBuffer.hh
trunk/source/tools/tDataEntry.hh
trunk/source/tools/tDataEntryBase.hh
trunk/source/tools/tDataEntryCommand.hh
trunk/source/tools/tDataManager.hh
trunk/source/tools/tDictionary.hh
trunk/source/tools/tHashTable.hh
trunk/source/tools/tList.hh
trunk/source/tools/tMatrix.hh
trunk/source/tools/tMemTrack.hh
trunk/source/tools/tVector.hh
trunk/source/tools/tools.cc
trunk/source/tools/tools.hh
trunk/source/tools/uint.hh
trunk/source/tools/weighted_index.cc
trunk/source/tools/weighted_index.hh
Modified:
trunk/Avida2.xcodeproj/project.pbxproj
trunk/source/bindings/Boost.Python/analyze_command.pyste
trunk/source/bindings/Boost.Python/phenotype.pyste
trunk/source/bindings/Boost.Python/population_interface.pyste
trunk/source/bindings/Boost.Python/random.pyste
trunk/source/bindings/Boost.Python/tArray_instantiations.hh
trunk/source/bindings/Boost.Python/tBuffer_instantiations.hh
trunk/source/bindings/Boost.Python/tDictionary_instantiations.hh
trunk/source/bindings/Boost.Python/tList_instantiations.hh
trunk/source/bindings/Boost.Python/tMatrix_instantiations.hh
trunk/source/bindings/Boost.Python/tVector_instantiations.hh
trunk/source/bindings/Boost.Python/tools.pyste
trunk/source/bindings/Boost.Python/uint.pyste
trunk/source/bindings/Boost.Python/weighted_index.pyste
trunk/source/cpu/cCPUMemory.h
trunk/source/cpu/cCPUTestInfo.h
trunk/source/cpu/cCodeLabel.cc
trunk/source/cpu/cCodeLabel.h
trunk/source/cpu/cHardware4Stack.h
trunk/source/cpu/cHardware4Stack_Thread.h
trunk/source/cpu/cHardwareCPU.h
trunk/source/cpu/cHardwareCPU_Thread.h
trunk/source/cpu/cHardwareFactory.h
trunk/source/cpu/cHardwareSMT.cc
trunk/source/cpu/cHardwareSMT.h
trunk/source/cpu/cHardwareSMT_Thread.h
trunk/source/cpu/cHardwareUtil.cc
trunk/source/cpu/cTestCPU.cc
trunk/source/cpu/cTestCPU.h
trunk/source/event/cEventFactoryManager.h
trunk/source/event/cPopulationEventFactory.cc
trunk/source/main/cAnalyze.cc
trunk/source/main/cAnalyze.h
trunk/source/main/cAnalyzeFlowCommand.h
trunk/source/main/cAnalyzeFlowCommandDef.h
trunk/source/main/cAnalyzeFunction.h
trunk/source/main/cAnalyzeGenotype.h
trunk/source/main/cAnalyzeUtil.cc
trunk/source/main/cAvidaDriver_Population.cc
trunk/source/main/cBirthChamber.cc
trunk/source/main/cConfig.cc
trunk/source/main/cConfig.h
trunk/source/main/cEnvironment.cc
trunk/source/main/cEnvironment.h
trunk/source/main/cFitnessMatrix.h
trunk/source/main/cGenebank.h
trunk/source/main/cGenome.h
trunk/source/main/cGenotype.cc
trunk/source/main/cGenotypeBatch.h
trunk/source/main/cGenotype_BirthData.h
trunk/source/main/cInjectGenotype.cc
trunk/source/main/cInstSet.cc
trunk/source/main/cInstSet.h
trunk/source/main/cLandscape.cc
trunk/source/main/cLandscape.h
trunk/source/main/cLocalMutations.h
trunk/source/main/cMutationLib.h
trunk/source/main/cMutationRates.cc
trunk/source/main/cMxCodeArray.cc
trunk/source/main/cOrganism.cc
trunk/source/main/cOrganism.h
trunk/source/main/cPhenotype.cc
trunk/source/main/cPhenotype.h
trunk/source/main/cPopulation.h
trunk/source/main/cPopulationCell.cc
trunk/source/main/cPopulationCell.h
trunk/source/main/cReaction.h
trunk/source/main/cReactionLib.h
trunk/source/main/cReactionRequisite.h
trunk/source/main/cReactionResult.h
trunk/source/main/cResourceCount.h
trunk/source/main/cResourceLib.h
trunk/source/main/cSpatialCountElem.h
trunk/source/main/cSpatialResCount.h
trunk/source/main/cStats.cc
trunk/source/main/cStats.h
trunk/source/main/cTaskLib.h
trunk/source/testsuites/unit_testsuites/tArgDataEntry.t.cc
trunk/source/testsuites/unit_testsuites/tArray.t.cc
trunk/source/testsuites/unit_testsuites/tBuffer.t.cc
trunk/source/testsuites/unit_testsuites/tDataEntry.t.cc
trunk/source/testsuites/unit_testsuites/tDataEntryBase.t.cc
trunk/source/testsuites/unit_testsuites/tDataEntryCommand.t.cc
trunk/source/testsuites/unit_testsuites/tDataManager.t.cc
trunk/source/testsuites/unit_testsuites/tDictionary.t.cc
trunk/source/testsuites/unit_testsuites/tList.t.cc
trunk/source/testsuites/unit_testsuites/tMatrix.t.cc
trunk/source/testsuites/unit_testsuites/tVector.t.cc
trunk/source/testsuites/unit_testsuites/tools.t.cc
trunk/source/testsuites/unit_testsuites/uint.t.cc
trunk/source/testsuites/unit_testsuites/weighted_index.t.cc
trunk/source/tools/CMakeLists.txt
trunk/source/tools/cBlockStruct.h
trunk/source/tools/cChangeList.h
trunk/source/tools/cConstSchedule.h
trunk/source/tools/cDataFileManager.h
trunk/source/tools/cFile.cc
trunk/source/tools/cFixedCoords.h
trunk/source/tools/cHelpManager.cc
trunk/source/tools/cHelpManager.h
trunk/source/tools/cHelpType.h
trunk/source/tools/cIndexedBlockStruct.h
trunk/source/tools/cInitFile.h
trunk/source/tools/cIntegratedSchedule.h
trunk/source/tools/cIntegratedScheduleNode.h
trunk/source/tools/cProbSchedule.cc
trunk/source/tools/cProbSchedule.h
trunk/source/tools/cRandom.cc
trunk/source/tools/cStringIterator.h
trunk/source/tools/cStringList.h
trunk/source/tools/cStringUtil.cc
trunk/source/tools/functions.h
trunk/source/tools/tObjectFactory.h
trunk/source/tools/tools.pri
trunk/source/utils/hist_map/Makefile
trunk/source/utils/hist_map/hist_map.cc
trunk/source/utils/hist_map/hist_map2.cc
trunk/source/utils/task_events/task_event_gen.cc
trunk/source/utils/task_events/task_event_gen.old.cc
trunk/source/viewers/text_window.hh
trunk/status.xml
Log:
Rename various remaining templates in tools.
Modified: trunk/Avida2.xcodeproj/project.pbxproj
===================================================================
--- trunk/Avida2.xcodeproj/project.pbxproj 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/Avida2.xcodeproj/project.pbxproj 2005-10-10 23:44:52 UTC (rev 339)
@@ -9,8 +9,6 @@
/* Begin PBXBuildFile section */
700E2996085A1F6000CF158A /* primitive in CopyFiles */ = {isa = PBXBuildFile; fileRef = DCC3164D07626CF3008F7A48 /* primitive */; };
700E2AF8085DE50C00CF158A /* avida.cc in Sources */ = {isa = PBXBuildFile; fileRef = DCC3109C0762539E008F7A48 /* avida.cc */; };
- 700E2B43085DE50C00CF158A /* weighted_index.cc in Sources */ = {isa = PBXBuildFile; fileRef = DCC315B3076253A5008F7A48 /* weighted_index.cc */; };
- 700E2B44085DE50C00CF158A /* tools.cc in Sources */ = {isa = PBXBuildFile; fileRef = DCC315AA076253A4008F7A48 /* tools.cc */; };
700E2B6F085DE50C00CF158A /* analyze.cfg in CopyFiles */ = {isa = PBXBuildFile; fileRef = DCC3114B0762539E008F7A48 /* analyze.cfg */; };
700E2B70085DE50C00CF158A /* environment.cfg in CopyFiles */ = {isa = PBXBuildFile; fileRef = DCC311800762539F008F7A48 /* environment.cfg */; };
700E2B71085DE50C00CF158A /* events.cfg in CopyFiles */ = {isa = PBXBuildFile; fileRef = DCC311810762539F008F7A48 /* events.cfg */; };
@@ -192,6 +190,10 @@
70B0894608F7630100FC65FE /* cStringIterator.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0892408F7630100FC65FE /* cStringIterator.cc */; };
70B0894708F7630100FC65FE /* cStringList.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0892508F7630100FC65FE /* cStringList.cc */; };
70B0894808F7630100FC65FE /* cStringUtil.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0892608F7630100FC65FE /* cStringUtil.cc */; };
+ 70B08B9208FB2E6B00FC65FE /* cTools.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B08B9008FB2E6B00FC65FE /* cTools.cc */; };
+ 70B08B9308FB2E6B00FC65FE /* cWeightedIndex.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B08B9108FB2E6B00FC65FE /* cWeightedIndex.cc */; };
+ 70B08B9408FB2E6B00FC65FE /* cTools.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B08B9008FB2E6B00FC65FE /* cTools.cc */; };
+ 70B08B9508FB2E6B00FC65FE /* cWeightedIndex.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B08B9108FB2E6B00FC65FE /* cWeightedIndex.cc */; };
70C1EF4808C393BA00F50912 /* cCodeLabel.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70C1EF4608C393BA00F50912 /* cCodeLabel.cc */; };
70C1EF4A08C393BA00F50912 /* cCodeLabel.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70C1EF4608C393BA00F50912 /* cCodeLabel.cc */; };
70C1EF5908C3948C00F50912 /* cCPUMemory.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70C1EF5808C3948C00F50912 /* cCPUMemory.cc */; };
@@ -274,8 +276,6 @@
70D46935085F61DD004C8409 /* trionan.c in Sources */ = {isa = PBXBuildFile; fileRef = DCC31471076253A1008F7A48 /* trionan.c */; };
70D46936085F61DF004C8409 /* triostr.c in Sources */ = {isa = PBXBuildFile; fileRef = DCC31474076253A1008F7A48 /* triostr.c */; };
DCC3166107628531008F7A48 /* avida.cc in Sources */ = {isa = PBXBuildFile; fileRef = DCC3109C0762539E008F7A48 /* avida.cc */; };
- DCC316B807628742008F7A48 /* weighted_index.cc in Sources */ = {isa = PBXBuildFile; fileRef = DCC315B3076253A5008F7A48 /* weighted_index.cc */; };
- DCC316B907628744008F7A48 /* tools.cc in Sources */ = {isa = PBXBuildFile; fileRef = DCC315AA076253A4008F7A48 /* tools.cc */; };
/* End PBXBuildFile section */
/* Begin PBXBuildStyle section */
@@ -541,6 +541,24 @@
70B0892408F7630100FC65FE /* cStringIterator.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cStringIterator.cc; sourceTree = "<group>"; };
70B0892508F7630100FC65FE /* cStringList.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cStringList.cc; sourceTree = "<group>"; };
70B0892608F7630100FC65FE /* cStringUtil.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cStringUtil.cc; sourceTree = "<group>"; };
+ 70B08B8008FB2E5500FC65FE /* cTools.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cTools.h; sourceTree = "<group>"; };
+ 70B08B8108FB2E5500FC65FE /* cUInt.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cUInt.h; sourceTree = "<group>"; };
+ 70B08B8208FB2E5500FC65FE /* cWeightedIndex.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cWeightedIndex.h; sourceTree = "<group>"; };
+ 70B08B8308FB2E5500FC65FE /* tArgDataEntry.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = tArgDataEntry.h; sourceTree = "<group>"; };
+ 70B08B8408FB2E5500FC65FE /* tArray.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = tArray.h; sourceTree = "<group>"; };
+ 70B08B8508FB2E5500FC65FE /* tBuffer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = tBuffer.h; sourceTree = "<group>"; };
+ 70B08B8608FB2E5500FC65FE /* tDataEntry.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = tDataEntry.h; sourceTree = "<group>"; };
+ 70B08B8708FB2E5500FC65FE /* tDataEntryBase.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = tDataEntryBase.h; sourceTree = "<group>"; };
+ 70B08B8808FB2E5500FC65FE /* tDataEntryCommand.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = tDataEntryCommand.h; sourceTree = "<group>"; };
+ 70B08B8908FB2E5500FC65FE /* tDataManager.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = tDataManager.h; sourceTree = "<group>"; };
+ 70B08B8A08FB2E5500FC65FE /* tDictionary.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = tDictionary.h; sourceTree = "<group>"; };
+ 70B08B8B08FB2E5500FC65FE /* tHashTable.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = tHashTable.h; sourceTree = "<group>"; };
+ 70B08B8C08FB2E5500FC65FE /* tList.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = tList.h; sourceTree = "<group>"; };
+ 70B08B8D08FB2E5500FC65FE /* tMatrix.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = tMatrix.h; sourceTree = "<group>"; };
+ 70B08B8E08FB2E5500FC65FE /* tMemTrack.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = tMemTrack.h; sourceTree = "<group>"; };
+ 70B08B8F08FB2E5500FC65FE /* tVector.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = tVector.h; sourceTree = "<group>"; };
+ 70B08B9008FB2E6B00FC65FE /* cTools.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cTools.cc; sourceTree = "<group>"; };
+ 70B08B9108FB2E6B00FC65FE /* cWeightedIndex.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cWeightedIndex.cc; sourceTree = "<group>"; };
70C1EF4608C393BA00F50912 /* cCodeLabel.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cCodeLabel.cc; sourceTree = "<group>"; };
70C1EF4708C393BA00F50912 /* cCodeLabel.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cCodeLabel.h; sourceTree = "<group>"; };
70C1EF5808C3948C00F50912 /* cCPUMemory.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cCPUMemory.cc; sourceTree = "<group>"; };
@@ -833,7 +851,6 @@
70CD47EE089692AE0070D2DF /* test_cpu-fixups.hh */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = "test_cpu-fixups.hh"; sourceTree = "<group>"; };
70CD47EF089692AE0070D2DF /* tVector_instantiations.hh */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = tVector_instantiations.hh; sourceTree = "<group>"; };
70CD47F0089692AE0070D2DF /* tVector.pyste */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = tVector.pyste; sourceTree = "<group>"; };
- 70FB868608BFA02D00BDF589 /* tHashTable.hh */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = tHashTable.hh; sourceTree = "<group>"; };
70FB86A908BFAFEC00BDF589 /* CMakeLists.txt */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = "<group>"; };
DCC30D300762539B008F7A48 /* 4stack_head.pyste */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = 4stack_head.pyste; sourceTree = "<group>"; };
DCC30D310762539B008F7A48 /* A.hh */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = A.hh; sourceTree = "<group>"; };
@@ -1343,30 +1360,13 @@
DCC31585076253A4008F7A48 /* recursive_tests_decl_hdrs.hh */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = recursive_tests_decl_hdrs.hh; sourceTree = "<group>"; };
DCC31586076253A4008F7A48 /* recursive_tests_defn_hdrs.hh */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = recursive_tests_defn_hdrs.hh; sourceTree = "<group>"; };
DCC31587076253A4008F7A48 /* recursive_tests_macros.hh */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = recursive_tests_macros.hh; sourceTree = "<group>"; };
- DCC31598076253A4008F7A48 /* tArgDataEntry.hh */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = tArgDataEntry.hh; sourceTree = "<group>"; };
- DCC31599076253A4008F7A48 /* tArray.hh */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = tArray.hh; sourceTree = "<group>"; };
- DCC3159A076253A4008F7A48 /* tBuffer.hh */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = tBuffer.hh; sourceTree = "<group>"; };
- DCC3159B076253A4008F7A48 /* tDataEntry.hh */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = tDataEntry.hh; sourceTree = "<group>"; };
- DCC3159C076253A4008F7A48 /* tDataEntryBase.hh */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = tDataEntryBase.hh; sourceTree = "<group>"; };
- DCC3159D076253A4008F7A48 /* tDataEntryCommand.hh */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = tDataEntryCommand.hh; sourceTree = "<group>"; };
- DCC3159E076253A4008F7A48 /* tDataManager.hh */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = tDataManager.hh; sourceTree = "<group>"; };
- DCC3159F076253A4008F7A48 /* tDictionary.hh */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = tDictionary.hh; sourceTree = "<group>"; };
DCC315A5076253A4008F7A48 /* CMakeLists.txt */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = "<group>"; };
DCC315A6076253A4008F7A48 /* UnitTest_recursive_tests.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = UnitTest_recursive_tests.cc; sourceTree = "<group>"; };
- DCC315A7076253A4008F7A48 /* tList.hh */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = tList.hh; sourceTree = "<group>"; };
- DCC315A8076253A4008F7A48 /* tMatrix.hh */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = tMatrix.hh; sourceTree = "<group>"; };
- DCC315A9076253A4008F7A48 /* tMemTrack.hh */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = tMemTrack.hh; sourceTree = "<group>"; };
- DCC315AA076253A4008F7A48 /* tools.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = tools.cc; sourceTree = "<group>"; };
- DCC315AB076253A4008F7A48 /* tools.hh */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = tools.hh; sourceTree = "<group>"; };
DCC315AC076253A5008F7A48 /* tools.pri */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = tools.pri; sourceTree = "<group>"; };
DCC315AD076253A5008F7A48 /* tUnitTestSuite.hh */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = tUnitTestSuite.hh; sourceTree = "<group>"; };
DCC315AE076253A5008F7A48 /* tUnitTestSuiteRecurser.hh */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = tUnitTestSuiteRecurser.hh; sourceTree = "<group>"; };
- DCC315AF076253A5008F7A48 /* tVector.hh */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = tVector.hh; sourceTree = "<group>"; };
DCC315B0076253A5008F7A48 /* tVerifierSuite.hh */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = tVerifierSuite.hh; sourceTree = "<group>"; };
DCC315B1076253A5008F7A48 /* tVerifierSuiteRecurser.hh */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = tVerifierSuiteRecurser.hh; sourceTree = "<group>"; };
- DCC315B2076253A5008F7A48 /* uint.hh */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = uint.hh; sourceTree = "<group>"; };
- DCC315B3076253A5008F7A48 /* weighted_index.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = weighted_index.cc; sourceTree = "<group>"; };
- DCC315B4076253A5008F7A48 /* weighted_index.hh */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = weighted_index.hh; sourceTree = "<group>"; };
DCC315B5076253A5008F7A48 /* win32_mkdir_hack.hh */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = win32_mkdir_hack.hh; sourceTree = "<group>"; };
DCC315BB076253A5008F7A48 /* fixHeaders.py */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.script.python; path = fixHeaders.py; sourceTree = "<group>"; };
DCC315C1076253A5008F7A48 /* hist_map.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = hist_map.cc; sourceTree = "<group>"; };
@@ -2705,6 +2705,24 @@
DCC314D8076253A2008F7A48 /* tools */ = {
isa = PBXGroup;
children = (
+ 70B08B9008FB2E6B00FC65FE /* cTools.cc */,
+ 70B08B9108FB2E6B00FC65FE /* cWeightedIndex.cc */,
+ 70B08B8008FB2E5500FC65FE /* cTools.h */,
+ 70B08B8108FB2E5500FC65FE /* cUInt.h */,
+ 70B08B8208FB2E5500FC65FE /* cWeightedIndex.h */,
+ 70B08B8308FB2E5500FC65FE /* tArgDataEntry.h */,
+ 70B08B8408FB2E5500FC65FE /* tArray.h */,
+ 70B08B8508FB2E5500FC65FE /* tBuffer.h */,
+ 70B08B8608FB2E5500FC65FE /* tDataEntry.h */,
+ 70B08B8708FB2E5500FC65FE /* tDataEntryBase.h */,
+ 70B08B8808FB2E5500FC65FE /* tDataEntryCommand.h */,
+ 70B08B8908FB2E5500FC65FE /* tDataManager.h */,
+ 70B08B8A08FB2E5500FC65FE /* tDictionary.h */,
+ 70B08B8B08FB2E5500FC65FE /* tHashTable.h */,
+ 70B08B8C08FB2E5500FC65FE /* tList.h */,
+ 70B08B8D08FB2E5500FC65FE /* tMatrix.h */,
+ 70B08B8E08FB2E5500FC65FE /* tMemTrack.h */,
+ 70B08B8F08FB2E5500FC65FE /* tVector.h */,
70B0891608F7630100FC65FE /* cHelpAlias.cc */,
70B0891708F7630100FC65FE /* cHelpManager.cc */,
70B0891808F7630100FC65FE /* cHelpType.cc */,
@@ -2784,35 +2802,17 @@
70B087DC08F5F4A900FC65FE /* cCycleCheck.h */,
70B087DD08F5F4A900FC65FE /* cID.h */,
70B087DE08F5F4A900FC65FE /* cVerifierSuiteRecurser.h */,
- 70FB868608BFA02D00BDF589 /* tHashTable.hh */,
DCC31547076253A4008F7A48 /* cCycleCheck.cc */,
DCC3154A076253A4008F7A48 /* CMakeLists.txt */,
DCC31585076253A4008F7A48 /* recursive_tests_decl_hdrs.hh */,
DCC31586076253A4008F7A48 /* recursive_tests_defn_hdrs.hh */,
DCC31587076253A4008F7A48 /* recursive_tests_macros.hh */,
- DCC31598076253A4008F7A48 /* tArgDataEntry.hh */,
- DCC31599076253A4008F7A48 /* tArray.hh */,
- DCC3159A076253A4008F7A48 /* tBuffer.hh */,
- DCC3159B076253A4008F7A48 /* tDataEntry.hh */,
- DCC3159C076253A4008F7A48 /* tDataEntryBase.hh */,
- DCC3159D076253A4008F7A48 /* tDataEntryCommand.hh */,
- DCC3159E076253A4008F7A48 /* tDataManager.hh */,
- DCC3159F076253A4008F7A48 /* tDictionary.hh */,
DCC315A0076253A4008F7A48 /* tests */,
- DCC315A7076253A4008F7A48 /* tList.hh */,
- DCC315A8076253A4008F7A48 /* tMatrix.hh */,
- DCC315A9076253A4008F7A48 /* tMemTrack.hh */,
- DCC315AA076253A4008F7A48 /* tools.cc */,
- DCC315AB076253A4008F7A48 /* tools.hh */,
DCC315AC076253A5008F7A48 /* tools.pri */,
DCC315AD076253A5008F7A48 /* tUnitTestSuite.hh */,
DCC315AE076253A5008F7A48 /* tUnitTestSuiteRecurser.hh */,
- DCC315AF076253A5008F7A48 /* tVector.hh */,
DCC315B0076253A5008F7A48 /* tVerifierSuite.hh */,
DCC315B1076253A5008F7A48 /* tVerifierSuiteRecurser.hh */,
- DCC315B2076253A5008F7A48 /* uint.hh */,
- DCC315B3076253A5008F7A48 /* weighted_index.cc */,
- DCC315B4076253A5008F7A48 /* weighted_index.hh */,
DCC315B5076253A5008F7A48 /* win32_mkdir_hack.hh */,
700E28CF0859FFD700CF158A /* tObjectFactory.h */,
);
@@ -3018,8 +3018,6 @@
buildActionMask = 2147483647;
files = (
700E2AF8085DE50C00CF158A /* avida.cc in Sources */,
- 700E2B43085DE50C00CF158A /* weighted_index.cc in Sources */,
- 700E2B44085DE50C00CF158A /* tools.cc in Sources */,
70658C35085DE5D800486BED /* ansi.cc in Sources */,
70658C36085DE5D900486BED /* bar_screen.cc in Sources */,
70658C38085DE5DC00486BED /* environment_screen.cc in Sources */,
@@ -3141,6 +3139,8 @@
70B0894608F7630100FC65FE /* cStringIterator.cc in Sources */,
70B0894708F7630100FC65FE /* cStringList.cc in Sources */,
70B0894808F7630100FC65FE /* cStringUtil.cc in Sources */,
+ 70B08B9208FB2E6B00FC65FE /* cTools.cc in Sources */,
+ 70B08B9308FB2E6B00FC65FE /* cWeightedIndex.cc in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -3149,8 +3149,6 @@
buildActionMask = 2147483647;
files = (
DCC3166107628531008F7A48 /* avida.cc in Sources */,
- DCC316B807628742008F7A48 /* weighted_index.cc in Sources */,
- DCC316B907628744008F7A48 /* tools.cc in Sources */,
70658C44085DE5FF00486BED /* primitive.cc in Sources */,
70D46934085F61DA004C8409 /* trio.c in Sources */,
70D46935085F61DD004C8409 /* trionan.c in Sources */,
@@ -3262,6 +3260,8 @@
70B0893508F7630100FC65FE /* cStringIterator.cc in Sources */,
70B0893608F7630100FC65FE /* cStringList.cc in Sources */,
70B0893708F7630100FC65FE /* cStringUtil.cc in Sources */,
+ 70B08B9408FB2E6B00FC65FE /* cTools.cc in Sources */,
+ 70B08B9508FB2E6B00FC65FE /* cWeightedIndex.cc in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Modified: trunk/source/bindings/Boost.Python/analyze_command.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/analyze_command.pyste 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/bindings/Boost.Python/analyze_command.pyste 2005-10-10 23:44:52 UTC (rev 339)
@@ -1,5 +1,5 @@
-Include("tList.hh")
+Include("tList.h")
cAnalyzeCommand = Class("cAnalyzeCommand", "cAnalyzeCommand.h")
set_policy(cAnalyzeCommand.GetCommandList, return_internal_reference())
Modified: trunk/source/bindings/Boost.Python/phenotype.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/phenotype.pyste 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/bindings/Boost.Python/phenotype.pyste 2005-10-10 23:44:52 UTC (rev 339)
@@ -1,6 +1,6 @@
Include("cEnvironment.h")
-Include("tBuffer.hh")
+Include("tBuffer.h")
cPhenotype = Class("cPhenotype", "cPhenotype.h")
set_policy(cPhenotype.GetMerit, return_internal_reference())
Modified: trunk/source/bindings/Boost.Python/population_interface.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/population_interface.pyste 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/bindings/Boost.Python/population_interface.pyste 2005-10-10 23:44:52 UTC (rev 339)
@@ -4,7 +4,7 @@
Include("cOrganism.h")
Include("cOrgMessage.h")
Include("cPopulation.h")
-Include("tArray.hh")
+Include("tArray.h")
cPopulationInterface = Class("cPopulationInterface", "population_interface-fixups.hh")
Modified: trunk/source/bindings/Boost.Python/random.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/random.pyste 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/bindings/Boost.Python/random.pyste 2005-10-10 23:44:52 UTC (rev 339)
@@ -1,5 +1,5 @@
-Include("tList.hh")
+Include("tList.h")
cRandom = Class("cRandom", "cRandom.h")
Modified: trunk/source/bindings/Boost.Python/tArray_instantiations.hh
===================================================================
--- trunk/source/bindings/Boost.Python/tArray_instantiations.hh 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/bindings/Boost.Python/tArray_instantiations.hh 2005-10-10 23:44:52 UTC (rev 339)
@@ -3,7 +3,7 @@
#include "cMutation.h"
#include "cIntSum.h"
-#include "tArray.hh"
+#include "tArray.h"
#include <exception>
Modified: trunk/source/bindings/Boost.Python/tBuffer_instantiations.hh
===================================================================
--- trunk/source/bindings/Boost.Python/tBuffer_instantiations.hh 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/bindings/Boost.Python/tBuffer_instantiations.hh 2005-10-10 23:44:52 UTC (rev 339)
@@ -1,2 +1,2 @@
-#include "tBuffer.hh"
+#include "tBuffer.h"
Modified: trunk/source/bindings/Boost.Python/tDictionary_instantiations.hh
===================================================================
--- trunk/source/bindings/Boost.Python/tDictionary_instantiations.hh 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/bindings/Boost.Python/tDictionary_instantiations.hh 2005-10-10 23:44:52 UTC (rev 339)
@@ -1,2 +1,2 @@
-#include "tDictionary.hh"
+#include "tDictionary.h"
Modified: trunk/source/bindings/Boost.Python/tList_instantiations.hh
===================================================================
--- trunk/source/bindings/Boost.Python/tList_instantiations.hh 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/bindings/Boost.Python/tList_instantiations.hh 2005-10-10 23:44:52 UTC (rev 339)
@@ -7,4 +7,4 @@
#include "cReaction.h"
#include "cString.h"
-#include "tList.hh"
+#include "tList.h"
Modified: trunk/source/bindings/Boost.Python/tMatrix_instantiations.hh
===================================================================
--- trunk/source/bindings/Boost.Python/tMatrix_instantiations.hh 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/bindings/Boost.Python/tMatrix_instantiations.hh 2005-10-10 23:44:52 UTC (rev 339)
@@ -1,2 +1,2 @@
-#include "tMatrix.hh"
+#include "tMatrix.h"
Modified: trunk/source/bindings/Boost.Python/tVector_instantiations.hh
===================================================================
--- trunk/source/bindings/Boost.Python/tVector_instantiations.hh 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/bindings/Boost.Python/tVector_instantiations.hh 2005-10-10 23:44:52 UTC (rev 339)
@@ -1,2 +1,2 @@
-#include "tVector.hh"
+#include "tVector.h"
Modified: trunk/source/bindings/Boost.Python/tools.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/tools.pyste 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/bindings/Boost.Python/tools.pyste 2005-10-10 23:44:52 UTC (rev 339)
@@ -1,6 +1,6 @@
Include("cString.h")
-cTools = Class("cTools", "tools.hh")
+cTools = Class("cTools", "cTools.h")
# vim: set ft=python:
Modified: trunk/source/bindings/Boost.Python/uint.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/uint.pyste 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/bindings/Boost.Python/uint.pyste 2005-10-10 23:44:52 UTC (rev 339)
@@ -1,4 +1,4 @@
-cUInt = Class("cUInt", "uint.hh")
+cUInt = Class("cUInt", "cUInt.h")
# vim: set ft=python:
Modified: trunk/source/bindings/Boost.Python/weighted_index.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/weighted_index.pyste 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/bindings/Boost.Python/weighted_index.pyste 2005-10-10 23:44:52 UTC (rev 339)
@@ -1,4 +1,4 @@
-cWeightedIndex = Class("cWeightedIndex", "weighted_index.hh")
+cWeightedIndex = Class("cWeightedIndex", "cWeightedIndex.h")
# vim: set ft=python:
Modified: trunk/source/cpu/cCPUMemory.h
===================================================================
--- trunk/source/cpu/cCPUMemory.h 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/cpu/cCPUMemory.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -12,7 +12,7 @@
#include "cGenome.h"
#endif
#ifndef TARRAY_HH
-#include "tArray.hh"
+#include "tArray.h"
#endif
#ifndef MEMORY_FLAGS_HH
#include "cMemoryFlags.h"
Modified: trunk/source/cpu/cCPUTestInfo.h
===================================================================
--- trunk/source/cpu/cCPUTestInfo.h 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/cpu/cCPUTestInfo.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -15,7 +15,7 @@
#include "cString.h"
#endif
#ifndef TARRAY_HH
-#include "tArray.hh"
+#include "tArray.h"
#endif
class cHardwareTracer;
Modified: trunk/source/cpu/cCodeLabel.cc
===================================================================
--- trunk/source/cpu/cCodeLabel.cc 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/cpu/cCodeLabel.cc 2005-10-10 23:44:52 UTC (rev 339)
@@ -7,7 +7,7 @@
#include "cCodeLabel.h"
-#include "tools.hh" // for g_memory & g_debug
+#include "cTools.h" // for g_memory & g_debug
#include "nHardwareCPU.h"
Modified: trunk/source/cpu/cCodeLabel.h
===================================================================
--- trunk/source/cpu/cCodeLabel.h 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/cpu/cCodeLabel.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -18,10 +18,10 @@
#include "cString.h"
#endif
#ifndef TARRAY_HH
-#include "tArray.hh"
+#include "tArray.h"
#endif
#ifndef TOOLS_HH
-#include "tools.hh"
+#include "cTools.h"
#endif
/**
Modified: trunk/source/cpu/cHardware4Stack.h
===================================================================
--- trunk/source/cpu/cHardware4Stack.h 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/cpu/cHardware4Stack.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -35,7 +35,7 @@
#include "cString.h"
#endif
#ifndef TARRAY_HH
-#include "tArray.hh"
+#include "tArray.h"
#endif
class cInstSet;
Modified: trunk/source/cpu/cHardware4Stack_Thread.h
===================================================================
--- trunk/source/cpu/cHardware4Stack_Thread.h 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/cpu/cHardware4Stack_Thread.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -23,7 +23,7 @@
#include "nHardware4Stack.h"
#endif
#ifndef TBUFFER_HH
-#include "tBuffer.hh"
+#include "tBuffer.h"
#endif
/**
Modified: trunk/source/cpu/cHardwareCPU.h
===================================================================
--- trunk/source/cpu/cHardwareCPU.h 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/cpu/cHardwareCPU.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -42,7 +42,7 @@
#include "cString.h"
#endif
#ifndef TARRAY_HH
-#include "tArray.hh"
+#include "tArray.h"
#endif
class cInstSet;
Modified: trunk/source/cpu/cHardwareCPU_Thread.h
===================================================================
--- trunk/source/cpu/cHardwareCPU_Thread.h 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/cpu/cHardwareCPU_Thread.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -26,7 +26,7 @@
#include "cCPUStack.h"
#endif
#ifndef TBUFFER_HH
-#include "tBuffer.hh"
+#include "tBuffer.h"
#endif
/**
Modified: trunk/source/cpu/cHardwareFactory.h
===================================================================
--- trunk/source/cpu/cHardwareFactory.h 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/cpu/cHardwareFactory.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -9,7 +9,7 @@
#define HARDWARE_FACTORY_HH
#ifndef TLIST_HH
-#include "tList.hh"
+#include "tList.h"
#endif
class cHardwareBase;
Modified: trunk/source/cpu/cHardwareSMT.cc
===================================================================
--- trunk/source/cpu/cHardwareSMT.cc 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/cpu/cHardwareSMT.cc 2005-10-10 23:44:52 UTC (rev 339)
@@ -30,22 +30,6 @@
using namespace std;
-// Positive integer exponentiation
-// O(log2(p))
-static int pow(int b, int p)
-{
- if (p == 0) return 1;
- if (p == 1) return b;
- if (p < 0) return 0;
-
- int r = 1;
- while (1) {
- if (p & 1) r *= b;
- if (!(p >>= 1)) return r;
- b *= b;
- }
-}
-
///////////////
// cHardwareSMT
///////////////
@@ -138,7 +122,7 @@
cHardwareSMT::cHardwareSMT(cOrganism* in_organism, cInstSet* in_inst_set)
: cHardwareBase(in_organism, in_inst_set), m_mem_array(1),
-m_mem_lbls(pow(nHardwareSMT::NUM_NOPS, nHardwareSMT::MAX_MEMSPACE_LABEL) / nHardwareSMT::MEM_LBLS_HASH_FACTOR)
+m_mem_lbls(Pow(nHardwareSMT::NUM_NOPS, nHardwareSMT::MAX_MEMSPACE_LABEL) / nHardwareSMT::MEM_LBLS_HASH_FACTOR)
{
m_functions = s_inst_slib->GetFunctions();
Modified: trunk/source/cpu/cHardwareSMT.h
===================================================================
--- trunk/source/cpu/cHardwareSMT.h 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/cpu/cHardwareSMT.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -37,13 +37,13 @@
#include "cString.h"
#endif
#ifndef TARRAY_HH
-#include "tArray.hh"
+#include "tArray.h"
#endif
#ifndef TINSTLIB_H
#include "tInstLib.h"
#endif
#ifndef THASH_TABLE_HH
-#include "tHashTable.hh"
+#include "tHashTable.h"
#endif
/**
Modified: trunk/source/cpu/cHardwareSMT_Thread.h
===================================================================
--- trunk/source/cpu/cHardwareSMT_Thread.h 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/cpu/cHardwareSMT_Thread.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -25,7 +25,7 @@
#include "nHardwareSMT.h"
#endif
#ifndef TBUFFER_HH
-#include "tBuffer.hh"
+#include "tBuffer.h"
#endif
/**
Modified: trunk/source/cpu/cHardwareUtil.cc
===================================================================
--- trunk/source/cpu/cHardwareUtil.cc 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/cpu/cHardwareUtil.cc 2005-10-10 23:44:52 UTC (rev 339)
@@ -34,7 +34,7 @@
#include "cInstSet.h"
#endif
#ifndef TDICTIONARY_HH
-#include "tDictionary.hh"
+#include "tDictionary.h"
#endif
using namespace std;
Modified: trunk/source/cpu/cTestCPU.cc
===================================================================
--- trunk/source/cpu/cTestCPU.cc 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/cpu/cTestCPU.cc 2005-10-10 23:44:52 UTC (rev 339)
@@ -22,7 +22,7 @@
#include "cResourceLib.h"
#include "cResource.h"
#include "cStringUtil.h"
-#include "tMatrix.hh"
+#include "tMatrix.h"
#include <iomanip>
Modified: trunk/source/cpu/cTestCPU.h
===================================================================
--- trunk/source/cpu/cTestCPU.h 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/cpu/cTestCPU.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -11,7 +11,7 @@
#include <fstream>
#ifndef TARRAY_HH
-#include "tArray.hh"
+#include "tArray.h"
#endif
#ifndef STRING_HH
#include "cString.h"
Modified: trunk/source/event/cEventFactoryManager.h
===================================================================
--- trunk/source/event/cEventFactoryManager.h 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/event/cEventFactoryManager.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -9,7 +9,7 @@
#define EVENT_FACTORY_MANAGER_HH
#ifndef TLIST_HH
-#include "tList.hh"
+#include "tList.h"
#endif
#ifndef TOBJECTFACTORY_H
Modified: trunk/source/event/cPopulationEventFactory.cc
===================================================================
--- trunk/source/event/cPopulationEventFactory.cc 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/event/cPopulationEventFactory.cc 2005-10-10 23:44:52 UTC (rev 339)
@@ -79,7 +79,7 @@
#include "cTestUtil.h"
#endif
#ifndef TOOLS_HH
-#include "tools.hh"
+#include "cTools.h"
#endif
#include <ctype.h> // for isdigit
Modified: trunk/source/main/cAnalyze.cc
===================================================================
--- trunk/source/main/cAnalyze.cc 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/main/cAnalyze.cc 2005-10-10 23:44:52 UTC (rev 339)
@@ -35,16 +35,16 @@
#include "cLandscape.h"
#include "cPhenotype.h"
#include "cSpecies.h"
-#include "tArgDataEntry.hh"
+#include "tArgDataEntry.h"
#include "cTaskEntry.h"
-#include "tDataEntry.hh"
-#include "tDataEntryCommand.hh"
-#include "tMatrix.hh"
+#include "tDataEntry.h"
+#include "tDataEntryCommand.h"
+#include "tMatrix.h"
#include "cTestCPU.h"
#include "cCPUTestInfo.h"
#include "cTestUtil.h"
#include "cResource.h"
-#include "tHashTable.hh"
+#include "tHashTable.h"
#ifdef WIN32
# include "win32_mkdir_hack.hh"
#endif
Modified: trunk/source/main/cAnalyze.h
===================================================================
--- trunk/source/main/cAnalyze.h 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/main/cAnalyze.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -26,7 +26,7 @@
#include "cStringList.h"
#endif
#ifndef TLIST_HH
-#include "tList.hh"
+#include "tList.h"
#endif
#define MAX_BATCHES 2000
Modified: trunk/source/main/cAnalyzeFlowCommand.h
===================================================================
--- trunk/source/main/cAnalyzeFlowCommand.h 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/main/cAnalyzeFlowCommand.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -12,7 +12,7 @@
#include "cAnalyzeCommand.h"
#endif
#ifndef TLIST_HH
-#include "tList.hh"
+#include "tList.h"
#endif
// cAnalyzeFlowCommand : A cAnalyzeCommand containing other commands
Modified: trunk/source/main/cAnalyzeFlowCommandDef.h
===================================================================
--- trunk/source/main/cAnalyzeFlowCommandDef.h 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/main/cAnalyzeFlowCommandDef.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -18,7 +18,7 @@
#include "cString.h"
#endif
#ifndef TLIST_HH
-#include "tList.hh"
+#include "tList.h"
#endif
class cAnalyze;
Modified: trunk/source/main/cAnalyzeFunction.h
===================================================================
--- trunk/source/main/cAnalyzeFunction.h 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/main/cAnalyzeFunction.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -15,7 +15,7 @@
#include "cString.h"
#endif
#ifndef TLIST_HH
-#include "tList.hh"
+#include "tList.h"
#endif
// cAnalyzeFunction : User-defined function
Modified: trunk/source/main/cAnalyzeGenotype.h
===================================================================
--- trunk/source/main/cAnalyzeGenotype.h 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/main/cAnalyzeGenotype.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -26,7 +26,7 @@
#include "cStringUtil.h"
#endif
#ifndef TARRAY_HH
-#include "tArray.hh"
+#include "tArray.h"
#endif
// cAnalyzeGenotype : Collection of information about loaded genotypes
Modified: trunk/source/main/cAnalyzeUtil.cc
===================================================================
--- trunk/source/main/cAnalyzeUtil.cc 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/main/cAnalyzeUtil.cc 2005-10-10 23:44:52 UTC (rev 339)
@@ -70,7 +70,7 @@
#include "cTestUtil.h"
#endif
#ifndef TOOLS_HH
-#include "tools.hh"
+#include "cTools.h"
#endif
#include <vector>
Modified: trunk/source/main/cAvidaDriver_Population.cc
===================================================================
--- trunk/source/main/cAvidaDriver_Population.cc 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/main/cAvidaDriver_Population.cc 2005-10-10 23:44:52 UTC (rev 339)
@@ -24,7 +24,7 @@
#include "cPopulationEventFactory.h"
#include "cPopulationInterface.h"
#include "cString.h"
-#include "tools.hh"
+#include "cTools.h"
#include <iostream>
#include <iomanip>
Modified: trunk/source/main/cBirthChamber.cc
===================================================================
--- trunk/source/main/cBirthChamber.cc 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/main/cBirthChamber.cc 2005-10-10 23:44:52 UTC (rev 339)
@@ -10,7 +10,7 @@
#endif
#ifndef TARRAY_HH
-#include "tArray.hh"
+#include "tArray.h"
#endif
#ifndef CONFIG_HH
#include "cConfig.h"
@@ -34,7 +34,7 @@
#include "cOrganism.h"
#endif
#ifndef TOOLS_HH
-#include "tools.hh"
+#include "cTools.h"
#endif
cBirthChamber::cBirthChamber()
Modified: trunk/source/main/cConfig.cc
===================================================================
--- trunk/source/main/cConfig.cc 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/main/cConfig.cc 2005-10-10 23:44:52 UTC (rev 339)
@@ -11,7 +11,7 @@
#include "cEventFactoryManager.h"
#include "cGenesis.h"
#include "cPopulationEventFactory.h"
-#include "tools.hh"
+#include "cTools.h"
using namespace std;
Modified: trunk/source/main/cConfig.h
===================================================================
--- trunk/source/main/cConfig.h 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/main/cConfig.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -15,7 +15,7 @@
#include "cStringList.h"
#endif
#ifndef TLIST_HH
-#include "tList.hh"
+#include "tList.h"
#endif
#include "nGeometry.h"
Modified: trunk/source/main/cEnvironment.cc
===================================================================
--- trunk/source/main/cEnvironment.cc 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/main/cEnvironment.cc 2005-10-10 23:44:52 UTC (rev 339)
@@ -43,7 +43,7 @@
#include "cTaskEntry.h"
#endif
#ifndef TOOLS_HH
-#include "tools.hh"
+#include "cTools.h"
#endif
using namespace std;
Modified: trunk/source/main/cEnvironment.h
===================================================================
--- trunk/source/main/cEnvironment.h 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/main/cEnvironment.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -30,7 +30,7 @@
#include "cTaskLib.h"
#endif
#ifndef TLIST_HH
-#include "tList.hh"
+#include "tList.h"
#endif
class cResourceLib; // aggregate
Modified: trunk/source/main/cFitnessMatrix.h
===================================================================
--- trunk/source/main/cFitnessMatrix.h 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/main/cFitnessMatrix.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -36,7 +36,7 @@
#include "cStringUtil.h"
#endif
#ifndef TOOLS_HH
-#include "tools.hh"
+#include "cTools.h"
#endif
class cGenome;
Modified: trunk/source/main/cGenebank.h
===================================================================
--- trunk/source/main/cGenebank.h 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/main/cGenebank.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -23,7 +23,7 @@
#include "cString.h"
#endif
#ifndef TLIST_HH
-#include "tList.hh"
+#include "tList.h"
#endif
template <class T> class tList; // array
Modified: trunk/source/main/cGenome.h
===================================================================
--- trunk/source/main/cGenome.h 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/main/cGenome.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -17,7 +17,7 @@
#include "cString.h"
#endif
#ifndef TARRAY_HH
-#include "tArray.hh"
+#include "tArray.h"
#endif
/**
Modified: trunk/source/main/cGenotype.cc
===================================================================
--- trunk/source/main/cGenotype.cc 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/main/cGenotype.cc 2005-10-10 23:44:52 UTC (rev 339)
@@ -14,7 +14,7 @@
#include "cOrganism.h"
#include "cPhenotype.h"
#include "cTestCPU.h"
-#include "tools.hh"
+#include "cTools.h"
using namespace std;
Modified: trunk/source/main/cGenotypeBatch.h
===================================================================
--- trunk/source/main/cGenotypeBatch.h 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/main/cGenotypeBatch.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -12,7 +12,7 @@
#include "cString.h"
#endif
#ifndef TLIST_HH
-#include "tList.hh"
+#include "tList.h"
#endif
// cGenotypeBatch : Collection of cAnalyzeGenotypes
Modified: trunk/source/main/cGenotype_BirthData.h
===================================================================
--- trunk/source/main/cGenotype_BirthData.h 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/main/cGenotype_BirthData.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -13,7 +13,7 @@
#endif
#ifndef TARRAY_HH
-#include "tArray.hh"
+#include "tArray.h"
#endif
class cGenotype;
Modified: trunk/source/main/cInjectGenotype.cc
===================================================================
--- trunk/source/main/cInjectGenotype.cc 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/main/cInjectGenotype.cc 2005-10-10 23:44:52 UTC (rev 339)
@@ -13,7 +13,7 @@
#include "cConfig.h"
#endif
#ifndef TOOLS_HH
-#include "tools.hh"
+#include "cTools.h"
#endif
using namespace std;
Modified: trunk/source/main/cInstSet.cc
===================================================================
--- trunk/source/main/cInstSet.cc 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/main/cInstSet.cc 2005-10-10 23:44:52 UTC (rev 339)
@@ -13,7 +13,7 @@
#include "cStringUtil.h"
#endif
#ifndef TOOLS_HH
-#include "tools.hh"
+#include "cTools.h"
#endif
using namespace std;
Modified: trunk/source/main/cInstSet.h
===================================================================
--- trunk/source/main/cInstSet.h 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/main/cInstSet.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -14,7 +14,7 @@
#include "cString.h"
#endif
#ifndef TARRAY_HH
-#include "tArray.hh"
+#include "tArray.h"
#endif
#ifndef INSTRUCTION_HH
#include "cInstruction.h"
Modified: trunk/source/main/cLandscape.cc
===================================================================
--- trunk/source/main/cLandscape.cc 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/main/cLandscape.cc 2005-10-10 23:44:52 UTC (rev 339)
@@ -15,7 +15,7 @@
#include "cStats.h" // For GetUpdate in outputs...
#include "cTestCPU.h"
#include "cTestUtil.h"
-#include "tools.hh"
+#include "cTools.h"
using namespace std;
Modified: trunk/source/main/cLandscape.h
===================================================================
--- trunk/source/main/cLandscape.h 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/main/cLandscape.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -18,7 +18,7 @@
#include "cString.h"
#endif
#ifndef TMATRIX_HH
-#include "tMatrix.hh"
+#include "tMatrix.h"
#endif
#include <fstream>
Modified: trunk/source/main/cLocalMutations.h
===================================================================
--- trunk/source/main/cLocalMutations.h 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/main/cLocalMutations.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -9,7 +9,7 @@
#define LOCAL_MUTATIONS_HH
#ifndef TARRAY_HH
-#include "tArray.hh"
+#include "tArray.h"
#endif
class cMutationLib;
Modified: trunk/source/main/cMutationLib.h
===================================================================
--- trunk/source/main/cMutationLib.h 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/main/cMutationLib.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -9,10 +9,10 @@
#define MUTATION_LIB_HH
#ifndef TARRAY_HH
-#include "tArray.hh"
+#include "tArray.h"
#endif
#ifndef TLIST_HH
-#include "tList.hh"
+#include "tList.h"
#endif
class cMutation;
Modified: trunk/source/main/cMutationRates.cc
===================================================================
--- trunk/source/main/cMutationRates.cc 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/main/cMutationRates.cc 2005-10-10 23:44:52 UTC (rev 339)
@@ -10,7 +10,7 @@
#endif
#ifndef TOOLS_HH
-#include "tools.hh"
+#include "cTools.h"
#endif
////////////////////
Modified: trunk/source/main/cMxCodeArray.cc
===================================================================
--- trunk/source/main/cMxCodeArray.cc 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/main/cMxCodeArray.cc 2005-10-10 23:44:52 UTC (rev 339)
@@ -31,7 +31,7 @@
#include "cTestCPU.h"
#endif
#ifndef TOOLS_HH
-#include "tools.hh"
+#include "cTools.h"
#endif
#include <iomanip>
Modified: trunk/source/main/cOrganism.cc
===================================================================
--- trunk/source/main/cOrganism.cc 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/main/cOrganism.cc 2005-10-10 23:44:52 UTC (rev 339)
@@ -19,9 +19,9 @@
#include "cInstUtil.h"
#include "cOrgMessage.h"
#include "cStringUtil.h"
-#include "tArray.hh"
-#include "tools.hh"
-#include "tList.hh"
+#include "tArray.h"
+#include "cTools.h"
+#include "tList.h"
#include <iomanip>
Modified: trunk/source/main/cOrganism.h
===================================================================
--- trunk/source/main/cOrganism.h 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/main/cOrganism.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -33,7 +33,7 @@
#include "cPopulationInterface.h"
#endif
#ifndef TBUFFER_HH
-#include "tBuffer.hh"
+#include "tBuffer.h"
#endif
/**
Modified: trunk/source/main/cPhenotype.cc
===================================================================
--- trunk/source/main/cPhenotype.cc 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/main/cPhenotype.cc 2005-10-10 23:44:52 UTC (rev 339)
@@ -19,7 +19,7 @@
#include "cReactionResult.h"
#endif
#ifndef TOOLS_HH
-#include "tools.hh"
+#include "cTools.h"
#endif
#include <fstream>
Modified: trunk/source/main/cPhenotype.h
===================================================================
--- trunk/source/main/cPhenotype.h 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/main/cPhenotype.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -17,7 +17,7 @@
#include "cString.h"
#endif
#ifndef TARRAY_HH
-#include "tArray.hh"
+#include "tArray.h"
#endif
Modified: trunk/source/main/cPopulation.h
===================================================================
--- trunk/source/main/cPopulation.h 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/main/cPopulation.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -26,10 +26,10 @@
#include "cString.h"
#endif
#ifndef TARRAY_HH
-#include "tArray.hh"
+#include "tArray.h"
#endif
#ifndef TLIST_HH
-#include "tList.hh"
+#include "tList.h"
#endif
class cSchedule;
Modified: trunk/source/main/cPopulationCell.cc
===================================================================
--- trunk/source/main/cPopulationCell.cc 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/main/cPopulationCell.cc 2005-10-10 23:44:52 UTC (rev 339)
@@ -19,7 +19,7 @@
#include "cOrganism.h"
#endif
#ifndef TOOLS_HH
-#include "tools.hh"
+#include "cTools.h"
#endif
using namespace std;
Modified: trunk/source/main/cPopulationCell.h
===================================================================
--- trunk/source/main/cPopulationCell.h 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/main/cPopulationCell.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -14,10 +14,10 @@
#include "cMutationRates.h"
#endif
#ifndef TARRAY_HH
-#include "tArray.hh"
+#include "tArray.h"
#endif
#ifndef TLIST_HH
-#include "tList.hh"
+#include "tList.h"
#endif
class cPopulation;
Modified: trunk/source/main/cReaction.h
===================================================================
--- trunk/source/main/cReaction.h 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/main/cReaction.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -12,7 +12,7 @@
#include "cString.h"
#endif
#ifndef TLIST_HH
-#include "tList.hh"
+#include "tList.h"
#endif
class cString; // aggregate
Modified: trunk/source/main/cReactionLib.h
===================================================================
--- trunk/source/main/cReactionLib.h 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/main/cReactionLib.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -9,7 +9,7 @@
#define REACTION_LIB_HH
#ifndef TARRAY_HH
-#include "tArray.hh"
+#include "tArray.h"
#endif
class cReaction;
Modified: trunk/source/main/cReactionRequisite.h
===================================================================
--- trunk/source/main/cReactionRequisite.h 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/main/cReactionRequisite.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -9,7 +9,7 @@
#define REACTION_REQUISITE_HH
#ifndef TLIST_HH
-#include "tList.hh"
+#include "tList.h"
#endif
class cReaction;
Modified: trunk/source/main/cReactionResult.h
===================================================================
--- trunk/source/main/cReactionResult.h 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/main/cReactionResult.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -9,7 +9,7 @@
#define REACTION_RESULT_HH
#ifndef TARRAY_HH
-#include "tArray.hh"
+#include "tArray.h"
#endif
template <class T> class tArray; // aggregate
Modified: trunk/source/main/cResourceCount.h
===================================================================
--- trunk/source/main/cResourceCount.h 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/main/cResourceCount.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -15,10 +15,10 @@
#include "cString.h"
#endif
#ifndef TARRAY_HH
-#include "tArray.hh"
+#include "tArray.h"
#endif
#ifndef TMATRIX_HH
-#include "tMatrix.hh"
+#include "tMatrix.h"
#endif
template <class T> class tArray; // aggregate
Modified: trunk/source/main/cResourceLib.h
===================================================================
--- trunk/source/main/cResourceLib.h 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/main/cResourceLib.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -9,7 +9,7 @@
#define RESOURCE_LIB_HH
#ifndef TARRAY_HH
-#include "tArray.hh"
+#include "tArray.h"
#endif
class cResource;
Modified: trunk/source/main/cSpatialCountElem.h
===================================================================
--- trunk/source/main/cSpatialCountElem.h 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/main/cSpatialCountElem.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -9,7 +9,7 @@
#define SPATIAL_COUNT_ELEM_HH
#ifndef TARRAY_HH
-#include "tArray.hh"
+#include "tArray.h"
#endif
class cSpatialCountElem {
Modified: trunk/source/main/cSpatialResCount.h
===================================================================
--- trunk/source/main/cSpatialResCount.h 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/main/cSpatialResCount.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -12,7 +12,7 @@
#include "cSpatialCountElem.h"
#endif
#ifndef TARRAY_HH
-#include "tArray.hh"
+#include "tArray.h"
#endif
class cSpatialResCount {
Modified: trunk/source/main/cStats.cc
===================================================================
--- trunk/source/main/cStats.cc 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/main/cStats.cc 2005-10-10 23:44:52 UTC (rev 339)
@@ -11,7 +11,7 @@
#include "cDataFile.h"
#include "functions.h"
#include "cStringUtil.h"
-#include "tDataEntry.hh"
+#include "tDataEntry.h"
#include <math.h>
Modified: trunk/source/main/cStats.h
===================================================================
--- trunk/source/main/cStats.h 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/main/cStats.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -31,10 +31,10 @@
#include "cRunningAverage.h"
#endif
#ifndef TARRAY_HH
-#include "tArray.hh"
+#include "tArray.h"
#endif
#ifndef TDATAMANAGER_HH
-#include "tDataManager.hh"
+#include "tDataManager.h"
#endif
#include "nGeometry.h"
Modified: trunk/source/main/cTaskLib.h
===================================================================
--- trunk/source/main/cTaskLib.h 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/main/cTaskLib.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -9,13 +9,13 @@
#define TASK_LIB_HH
#ifndef TARRAY_HH
-#include "tArray.hh"
+#include "tArray.h"
#endif
#ifndef TBUFFER_HH
-#include "tBuffer.hh"
+#include "tBuffer.h"
#endif
#ifndef TLIST_HH
-#include "tList.hh"
+#include "tList.h"
#endif
class cTaskLib;
Modified: trunk/source/testsuites/unit_testsuites/tArgDataEntry.t.cc
===================================================================
--- trunk/source/testsuites/unit_testsuites/tArgDataEntry.t.cc 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/testsuites/unit_testsuites/tArgDataEntry.t.cc 2005-10-10 23:44:52 UTC (rev 339)
@@ -1,7 +1,7 @@
#include <iostream>
#ifndef TARGDATAENTRY_HH
-#include "tArgDataEntry.hh"
+#include "tArgDataEntry.h"
#endif
#ifndef TEST_CASE_H
#include "third-party/yaktest/cTestCase.hh"
Modified: trunk/source/testsuites/unit_testsuites/tArray.t.cc
===================================================================
--- trunk/source/testsuites/unit_testsuites/tArray.t.cc 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/testsuites/unit_testsuites/tArray.t.cc 2005-10-10 23:44:52 UTC (rev 339)
@@ -1,7 +1,7 @@
#include <iostream>
#ifndef TARRAY_HH
-#include "tArray.hh"
+#include "tArray.h"
#endif
#ifndef TEST_CASE_H
#include "third-party/yaktest/cTestCase.hh"
Modified: trunk/source/testsuites/unit_testsuites/tBuffer.t.cc
===================================================================
--- trunk/source/testsuites/unit_testsuites/tBuffer.t.cc 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/testsuites/unit_testsuites/tBuffer.t.cc 2005-10-10 23:44:52 UTC (rev 339)
@@ -1,7 +1,7 @@
#include <iostream>
#ifndef TBUFFER_HH
-#include "tBuffer.hh"
+#include "tBuffer.h"
#endif
#ifndef TEST_CASE_H
#include "third-party/yaktest/cTestCase.hh"
Modified: trunk/source/testsuites/unit_testsuites/tDataEntry.t.cc
===================================================================
--- trunk/source/testsuites/unit_testsuites/tDataEntry.t.cc 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/testsuites/unit_testsuites/tDataEntry.t.cc 2005-10-10 23:44:52 UTC (rev 339)
@@ -1,7 +1,7 @@
#include <iostream>
#ifndef TDATAENTRY_HH
-#include "tDataEntry.hh"
+#include "tDataEntry.h"
#endif
#ifndef TEST_CASE_H
#include "third-party/yaktest/cTestCase.hh"
Modified: trunk/source/testsuites/unit_testsuites/tDataEntryBase.t.cc
===================================================================
--- trunk/source/testsuites/unit_testsuites/tDataEntryBase.t.cc 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/testsuites/unit_testsuites/tDataEntryBase.t.cc 2005-10-10 23:44:52 UTC (rev 339)
@@ -1,7 +1,7 @@
#include <iostream>
#ifndef TDATAENTRYBASE_HH
-#include "tDataEntryBase.hh"
+#include "tDataEntryBase.h"
#endif
#ifndef TEST_CASE_H
#include "third-party/yaktest/cTestCase.hh"
Modified: trunk/source/testsuites/unit_testsuites/tDataEntryCommand.t.cc
===================================================================
--- trunk/source/testsuites/unit_testsuites/tDataEntryCommand.t.cc 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/testsuites/unit_testsuites/tDataEntryCommand.t.cc 2005-10-10 23:44:52 UTC (rev 339)
@@ -1,7 +1,7 @@
#include <iostream>
#ifndef TDATAENTRYCOMMAND_HH
-#include "tDataEntryCommand.hh"
+#include "tDataEntryCommand.h"
#endif
#ifndef TEST_CASE_H
#include "third-party/yaktest/cTestCase.hh"
Modified: trunk/source/testsuites/unit_testsuites/tDataManager.t.cc
===================================================================
--- trunk/source/testsuites/unit_testsuites/tDataManager.t.cc 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/testsuites/unit_testsuites/tDataManager.t.cc 2005-10-10 23:44:52 UTC (rev 339)
@@ -1,7 +1,7 @@
#include <iostream>
#ifndef TDATAMANAGER_HH
-#include "tDataManager.hh"
+#include "tDataManager.h"
#endif
#ifndef TEST_CASE_H
#include "third-party/yaktest/cTestCase.hh"
Modified: trunk/source/testsuites/unit_testsuites/tDictionary.t.cc
===================================================================
--- trunk/source/testsuites/unit_testsuites/tDictionary.t.cc 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/testsuites/unit_testsuites/tDictionary.t.cc 2005-10-10 23:44:52 UTC (rev 339)
@@ -1,7 +1,7 @@
#include <iostream>
#ifndef TDICTIONARY_HH
-#include "tDictionary.hh"
+#include "tDictionary.h"
#endif
#ifndef TEST_CASE_H
#include "third-party/yaktest/cTestCase.hh"
Modified: trunk/source/testsuites/unit_testsuites/tList.t.cc
===================================================================
--- trunk/source/testsuites/unit_testsuites/tList.t.cc 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/testsuites/unit_testsuites/tList.t.cc 2005-10-10 23:44:52 UTC (rev 339)
@@ -1,7 +1,7 @@
#include <iostream>
#ifndef TLIST_HH
-#include "tList.hh"
+#include "tList.h"
#endif
#ifndef TEST_CASE_H
#include "third-party/yaktest/cTestCase.hh"
Modified: trunk/source/testsuites/unit_testsuites/tMatrix.t.cc
===================================================================
--- trunk/source/testsuites/unit_testsuites/tMatrix.t.cc 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/testsuites/unit_testsuites/tMatrix.t.cc 2005-10-10 23:44:52 UTC (rev 339)
@@ -1,7 +1,7 @@
#include <iostream>
#ifndef TMATRIX_HH
-#include "tMatrix.hh"
+#include "tMatrix.h"
#endif
#ifndef TEST_CASE_H
#include "third-party/yaktest/cTestCase.hh"
Modified: trunk/source/testsuites/unit_testsuites/tVector.t.cc
===================================================================
--- trunk/source/testsuites/unit_testsuites/tVector.t.cc 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/testsuites/unit_testsuites/tVector.t.cc 2005-10-10 23:44:52 UTC (rev 339)
@@ -1,7 +1,7 @@
#include <iostream>
#ifndef TVECTOR_HH
-#include "tVector.hh"
+#include "tVector.h"
#endif
#ifndef TEST_CASE_H
#include "third-party/yaktest/cTestCase.hh"
Modified: trunk/source/testsuites/unit_testsuites/tools.t.cc
===================================================================
--- trunk/source/testsuites/unit_testsuites/tools.t.cc 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/testsuites/unit_testsuites/tools.t.cc 2005-10-10 23:44:52 UTC (rev 339)
@@ -1,7 +1,7 @@
#include <iostream>
#ifndef TOOLS_HH
-#include "tools.hh"
+#include "cTools.h"
#endif
#ifndef TEST_CASE_H
#include "third-party/yaktest/cTestCase.hh"
Modified: trunk/source/testsuites/unit_testsuites/uint.t.cc
===================================================================
--- trunk/source/testsuites/unit_testsuites/uint.t.cc 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/testsuites/unit_testsuites/uint.t.cc 2005-10-10 23:44:52 UTC (rev 339)
@@ -1,7 +1,7 @@
#include <iostream>
#ifndef UINT_HH
-#include "uint.hh"
+#include "cUInt.h"
#endif
#ifndef TEST_CASE_H
#include "third-party/yaktest/cTestCase.hh"
Modified: trunk/source/testsuites/unit_testsuites/weighted_index.t.cc
===================================================================
--- trunk/source/testsuites/unit_testsuites/weighted_index.t.cc 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/testsuites/unit_testsuites/weighted_index.t.cc 2005-10-10 23:44:52 UTC (rev 339)
@@ -1,7 +1,7 @@
#include <iostream>
#ifndef WEIGHTED_INDEX_HH
-#include "weighted_index.hh"
+#include "cWeightedIndex.h"
#endif
#ifndef TEST_CASE_H
#include "third-party/yaktest/cTestCase.hh"
Modified: trunk/source/tools/CMakeLists.txt
===================================================================
--- trunk/source/tools/CMakeLists.txt 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/tools/CMakeLists.txt 2005-10-10 23:44:52 UTC (rev 339)
@@ -33,8 +33,8 @@
cStringIterator.cc
cStringList.cc
cStringUtil.cc
- tools.cc
- weighted_index.cc
+ cTools.cc
+ cWeightedIndex.cc
cCycleCheck.cc
)
Modified: trunk/source/tools/cBlockStruct.h
===================================================================
--- trunk/source/tools/cBlockStruct.h 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/tools/cBlockStruct.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -18,7 +18,7 @@
#include "cScaledBlock.h"
#endif
#ifndef UINT_HH
-#include "uint.hh"
+#include "cUInt.h"
#endif
#define BLOCK_FLAG_FILL_IN 0
Modified: trunk/source/tools/cChangeList.h
===================================================================
--- trunk/source/tools/cChangeList.h 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/tools/cChangeList.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -9,7 +9,7 @@
#define CHANGE_LIST_HH
#ifndef TARRAY_HH
-#include "tArray.hh"
+#include "tArray.h"
#endif
/**
Modified: trunk/source/tools/cConstSchedule.h
===================================================================
--- trunk/source/tools/cConstSchedule.h 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/tools/cConstSchedule.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -12,7 +12,7 @@
#include "cSchedule.h"
#endif
#ifndef TARRAY_HH
-#include "tArray.hh"
+#include "tArray.h"
#endif
/**
Modified: trunk/source/tools/cDataFileManager.h
===================================================================
--- trunk/source/tools/cDataFileManager.h 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/tools/cDataFileManager.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -20,7 +20,7 @@
#include <fstream>
#ifndef TLIST_HH
-#include "tList.hh"
+#include "tList.h"
#endif
/**
Modified: trunk/source/tools/cFile.cc
===================================================================
--- trunk/source/tools/cFile.cc 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/tools/cFile.cc 2005-10-10 23:44:52 UTC (rev 339)
@@ -20,7 +20,7 @@
#endif
#ifndef TOOLS_HH
-#include "tools.hh" // for g_debug global
+#include "cTools.h" // for g_debug global
#endif
#include <iostream>
Modified: trunk/source/tools/cFixedCoords.h
===================================================================
--- trunk/source/tools/cFixedCoords.h 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/tools/cFixedCoords.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -9,7 +9,7 @@
#define FIXED_COORDS_HH
#ifndef UINT_HH
-#include "uint.hh"
+#include "cUInt.h"
#endif
/**
Modified: trunk/source/tools/cHelpManager.cc
===================================================================
--- trunk/source/tools/cHelpManager.cc 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/tools/cHelpManager.cc 2005-10-10 23:44:52 UTC (rev 339)
@@ -19,7 +19,7 @@
#include "cString.h"
#endif
#ifndef TLIST_HH
-#include "tList.hh"
+#include "tList.h"
#endif
#include <iostream>
Modified: trunk/source/tools/cHelpManager.h
===================================================================
--- trunk/source/tools/cHelpManager.h 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/tools/cHelpManager.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -15,7 +15,7 @@
#include "cString.h"
#endif
#ifndef TLIST_HH
-#include "tList.hh"
+#include "tList.h"
#endif
class cHelpFullEntry;
Modified: trunk/source/tools/cHelpType.h
===================================================================
--- trunk/source/tools/cHelpType.h 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/tools/cHelpType.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -12,7 +12,7 @@
#include "cString.h"
#endif
#ifndef TLIST_HH
-#include "tList.hh"
+#include "tList.h"
#endif
class cHelpAlias;
Modified: trunk/source/tools/cIndexedBlockStruct.h
===================================================================
--- trunk/source/tools/cIndexedBlockStruct.h 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/tools/cIndexedBlockStruct.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -28,7 +28,7 @@
#include "cRefBlock.h"
#endif
#ifndef UINT_HH
-#include "uint.hh"
+#include "cUInt.h"
#endif
class cFixedBlock; // accessed
Modified: trunk/source/tools/cInitFile.h
===================================================================
--- trunk/source/tools/cInitFile.h 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/tools/cInitFile.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -20,7 +20,7 @@
#include "cStringList.h"
#endif
#ifndef TARRAY_HH
-#include "tArray.hh"
+#include "tArray.h"
#endif
/**
Modified: trunk/source/tools/cIntegratedSchedule.h
===================================================================
--- trunk/source/tools/cIntegratedSchedule.h 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/tools/cIntegratedSchedule.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -12,7 +12,7 @@
#include "cSchedule.h"
#endif
#ifndef TARRAY_HH
-#include "tArray.hh"
+#include "tArray.h"
#endif
/**
Modified: trunk/source/tools/cIntegratedScheduleNode.h
===================================================================
--- trunk/source/tools/cIntegratedScheduleNode.h 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/tools/cIntegratedScheduleNode.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -9,7 +9,7 @@
#define INTEGRATED_SCHEDULE_NODE_HH
#ifndef TARRAY_HH
-#include "tArray.hh"
+#include "tArray.h"
#endif
/**
Modified: trunk/source/tools/cProbSchedule.cc
===================================================================
--- trunk/source/tools/cProbSchedule.cc 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/tools/cProbSchedule.cc 2005-10-10 23:44:52 UTC (rev 339)
@@ -9,7 +9,7 @@
#include "cChangeList.h"
#include "cMerit.h"
-#include "tools.hh"
+#include "cTools.h"
///////////////////
Modified: trunk/source/tools/cProbSchedule.h
===================================================================
--- trunk/source/tools/cProbSchedule.h 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/tools/cProbSchedule.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -12,7 +12,7 @@
#include "cSchedule.h"
#endif
#ifndef WEIGHTED_INDEX_HH
-#include "weighted_index.hh"
+#include "cWeightedIndex.h"
#endif
/**
Modified: trunk/source/tools/cRandom.cc
===================================================================
--- trunk/source/tools/cRandom.cc 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/tools/cRandom.cc 2005-10-10 23:44:52 UTC (rev 339)
@@ -10,7 +10,7 @@
#endif
#ifndef TARRAY_HH
-#include "tArray.hh"
+#include "tArray.h"
#endif
/* FIXME this is not defined in Visual Studio.net. -- kgn */
Modified: trunk/source/tools/cStringIterator.h
===================================================================
--- trunk/source/tools/cStringIterator.h 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/tools/cStringIterator.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -12,7 +12,7 @@
#include "cString.h"
#endif
#ifndef TLIST_HH
-#include "tList.hh"
+#include "tList.h"
#endif
class cString; // aggregate
Modified: trunk/source/tools/cStringList.h
===================================================================
--- trunk/source/tools/cStringList.h 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/tools/cStringList.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -12,7 +12,7 @@
#include "cString.h"
#endif
#ifndef TLIST_HH
-#include "tList.hh"
+#include "tList.h"
#endif
class cString; // aggregate
Modified: trunk/source/tools/cStringUtil.cc
===================================================================
--- trunk/source/tools/cStringUtil.cc 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/tools/cStringUtil.cc 2005-10-10 23:44:52 UTC (rev 339)
@@ -11,7 +11,7 @@
#include "functions.h"
-#include "tMatrix.hh"
+#include "tMatrix.h"
extern "C"{
#include <stdio.h>
Copied: trunk/source/tools/cTools.cc (from rev 338, trunk/source/tools/tools.cc)
===================================================================
--- trunk/source/tools/tools.cc 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/tools/cTools.cc 2005-10-10 23:44:52 UTC (rev 339)
@@ -0,0 +1,55 @@
+//////////////////////////////////////////////////////////////////////////////
+// Copyright (C) 1993 - 2001 California Institute of Technology //
+// //
+// Read the COPYING and README files, or contact 'avida at alife.org', //
+// before continuing. SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE. //
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef TOOLS_HH
+#include "cTools.h"
+#endif
+
+#include <iostream>
+#include <errno.h>
+#include <sys/stat.h>
+#include <stdio.h>
+
+#ifndef STRING_HH
+#include "cString.h"
+#endif
+
+#ifdef WIN32
+# ifndef WIN32_MKDIR_HACK_HH
+# include "win32_mkdir_hack.hh"
+# endif
+#endif
+
+cRandom g_random;
+
+using namespace std;
+
+bool cTools::MkDir(const cString & dirname, bool verbose)
+{
+ if (verbose) cout << "Checking for directory '" << dirname << "'..." << flush;
+
+ FILE * fp = fopen ( dirname(), "r" );
+ if (fp == 0) {
+ if (errno == ENOENT) {
+ if (verbose) cout << " not found, creating..." << flush;
+ if (mkdir( dirname(), (S_IRWXU|S_IRWXG|S_IRWXO) )) {
+ if (verbose)
+ cerr << endl << "Warning: Failed to create directory '" << dirname << "'." << endl;
+ return false;
+ }
+
+ if (verbose) cout << " done." << endl;
+ return true;
+ }
+
+ if (verbose) cout << "Warning: Failed to open '" << dirname << "'." << endl;
+ return false;
+ }
+
+ if (verbose) cout << " found." << endl;
+ return true;
+}
Copied: trunk/source/tools/cTools.h (from rev 338, trunk/source/tools/tools.hh)
Copied: trunk/source/tools/cUInt.h (from rev 338, trunk/source/tools/uint.hh)
Copied: trunk/source/tools/cWeightedIndex.cc (from rev 338, trunk/source/tools/weighted_index.cc)
===================================================================
--- trunk/source/tools/weighted_index.cc 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/tools/cWeightedIndex.cc 2005-10-10 23:44:52 UTC (rev 339)
@@ -0,0 +1,98 @@
+//////////////////////////////////////////////////////////////////////////////
+// Copyright (C) 1993 - 2002 California Institute of Technology //
+// //
+// Read the COPYING and README files, or contact 'avida at alife.org', //
+// before continuing. SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE. //
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef WEIGHTED_INDEX_HH
+#include "cWeightedIndex.h"
+#endif
+#include <iostream>
+
+
+using namespace std;
+
+
+cWeightedIndex::cWeightedIndex(int in_size)
+ : size(in_size)
+ , item_weight(size)
+ , subtree_weight(size)
+{
+ item_weight.SetAll(0);
+ subtree_weight.SetAll(0);
+}
+
+cWeightedIndex::~cWeightedIndex()
+{
+}
+
+void cWeightedIndex::AdjustSubtree(int id, double weight_change)
+{
+ subtree_weight[id] += weight_change;
+ if (id != 0) {
+ AdjustSubtree(GetParent(id), weight_change);
+ }
+}
+
+void cWeightedIndex::SetWeight(int id, double in_weight)
+{
+ const double weight_change = in_weight - item_weight[id];
+ item_weight[id] = in_weight;
+ AdjustSubtree(id, weight_change);
+}
+
+// This order of testing is about 10% faster than the one used below.
+// Alas, it scans the array out of bounds... For a real test we need to
+// look at timings in optimized mode.
+// int cWeightedIndex::FindPosition(double position, int root_id)
+// {
+// // Check left...
+// const int left_id = GetLeftChild(root_id);
+// if (position < subtree_weight[left_id]) {
+// return FindPosition(position, left_id);
+// }
+
+// // Then right...
+// position -= subtree_weight[left_id];
+// const int right_id = GetRightChild(root_id);
+// if (position < subtree_weight[right_id]) {
+// return FindPosition(position, right_id);
+// }
+
+// // Then just return this!
+// return root_id;
+// }
+
+int cWeightedIndex::FindPosition(double position, int root_id)
+{
+// cout << "Seeking " << position
+// << " at root " << root_id
+// << " subtree size = " << subtree_weight[root_id]
+// << " (left=" << subtree_weight[GetLeftChild(root_id)]
+// << " , right=" << subtree_weight[GetRightChild(root_id)]
+// << " , this=" << item_weight[root_id] << ")"
+// << endl;
+ assert(position < subtree_weight[root_id]);
+
+ // First, see if we should just return this node.
+ if (position < item_weight[root_id]) {
+ return root_id;
+ }
+
+ // If not, then see if we should search in the left subtree...
+ position -= item_weight[root_id];
+ const int left_id = GetLeftChild(root_id);
+ assert (left_id < size);
+ if (position < subtree_weight[left_id]) {
+ return FindPosition(position, left_id);
+ }
+
+ // Otherwise we must look in the right subtree...
+ position -= subtree_weight[left_id];
+ const int right_id = GetRightChild(root_id);
+ assert (right_id < size);
+ assert (position < subtree_weight[right_id]);
+ return FindPosition(position, right_id);
+}
+
Copied: trunk/source/tools/cWeightedIndex.h (from rev 338, trunk/source/tools/weighted_index.hh)
===================================================================
--- trunk/source/tools/weighted_index.hh 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/tools/cWeightedIndex.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -0,0 +1,48 @@
+//////////////////////////////////////////////////////////////////////////////
+// Copyright (C) 1993 - 2003 California Institute of Technology //
+// //
+// Read the COPYING and README files, or contact 'avida at alife.org', //
+// before continuing. SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE. //
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef WEIGHTED_INDEX_HH
+#define WEIGHTED_INDEX_HH
+
+#ifndef TARRAY_HH
+#include "tArray.h"
+#endif
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+/**
+ * This class allows indecies to be assigned a "weight" and then indexed by
+ * that weight.
+ **/
+
+template <class T> class tArray; // aggregate
+
+class cWeightedIndex {
+protected:
+ int size;
+ tArray<double> item_weight;
+ tArray<double> subtree_weight;
+
+ void AdjustSubtree(int id, double weight_change);
+public:
+ cWeightedIndex(int in_size);
+ ~cWeightedIndex();
+
+ void SetWeight(int id, double weight);
+ double GetWeight(int id) { return item_weight[id]; }
+
+ double GetTotalWeight() { return subtree_weight[0]; }
+ int FindPosition(double position, int root_id=0);
+
+ int GetParent(int id) { return (id-1) / 2; }
+ int GetLeftChild(int id) { return 2*id + 1; }
+ int GetRightChild(int id) { return 2*id + 2; }
+};
+
+#endif
Modified: trunk/source/tools/functions.h
===================================================================
--- trunk/source/tools/functions.h 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/tools/functions.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -14,7 +14,7 @@
#include <assert.h>
#ifndef TARRAY_HH
-#include "tArray.hh"
+#include "tArray.h"
#endif
template <class T> class tArray; // accessed
@@ -90,11 +90,20 @@
return value;
}
-inline int Pow(int base, int expon)
+// Positive integer exponentiation
+// O(log2(p))
+inline int Pow(int base, int p)
{
- int value = 1;
- for (int i = 0; i < expon; i++) value *= base;
- return value;
+ if (p == 0) return 1;
+ if (p == 1) return base;
+ if (p < 0) return 0;
+
+ int r = 1;
+ while (1) {
+ if (p & 1) r *= base;
+ if (!(p >>= 1)) return r;
+ base *= base;
+ }
}
inline double Log(double value)
Copied: trunk/source/tools/tArgDataEntry.h (from rev 338, trunk/source/tools/tArgDataEntry.hh)
===================================================================
--- trunk/source/tools/tArgDataEntry.hh 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/tools/tArgDataEntry.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -0,0 +1,48 @@
+//////////////////////////////////////////////////////////////////////////////
+// Copyright (C) 1993 - 2003 California Institute of Technology //
+// //
+// Read the COPYING and README files, or contact 'avida at alife.org', //
+// before continuing. SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE. //
+//////////////////////////////////////////////////////////////////////////////
+
+
+#ifndef TARGDATAENTRY_HH
+#define TARGDATAENTRY_HH
+
+#include <iostream>
+
+#ifndef TDATAENTRYBASE_HH
+#include "tDataEntryBase.h"
+#endif
+
+class cString;
+
+template <class T, class OUT, class ARG> class tArgDataEntry
+ : public tDataEntryBase<T> {
+protected:
+ OUT (T::*DataRetrieval)(ARG) const;
+ int (T::*DataCompare)(T*,ARG) const;
+ ARG arg;
+public:
+ tArgDataEntry(const cString & _name, const cString & _desc,
+ OUT (T::*_funR)(ARG) const, ARG _arg,
+ //int (T::*_funC)(T * _o, ARG _i) const = &T::CompareArgNULL,
+ int (T::*_funC)(T * _o, ARG _i) const = 0,
+ const cString & _null="0",
+ const cString & _html_cell="align=center")
+ : tDataEntryBase<T>(_name, _desc, _null, _html_cell),
+ DataRetrieval(_funR), DataCompare(_funC), arg(_arg) { ; }
+
+ bool Print(std::ostream & fp) const {
+ if (this->target == NULL) return false;
+ fp << (this->target->*DataRetrieval)(arg);
+ return true;
+ }
+
+ //int Compare(T * other) const { return (target->*DataCompare)(other, arg); }
+ int Compare(T * other) const {
+ return (DataCompare)?((this->target->*DataCompare)(other, arg)):(0);
+ }
+};
+
+#endif
Deleted: trunk/source/tools/tArgDataEntry.hh
===================================================================
--- trunk/source/tools/tArgDataEntry.hh 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/tools/tArgDataEntry.hh 2005-10-10 23:44:52 UTC (rev 339)
@@ -1,48 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// Copyright (C) 1993 - 2003 California Institute of Technology //
-// //
-// Read the COPYING and README files, or contact 'avida at alife.org', //
-// before continuing. SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE. //
-//////////////////////////////////////////////////////////////////////////////
-
-
-#ifndef TARGDATAENTRY_HH
-#define TARGDATAENTRY_HH
-
-#include <iostream>
-
-#ifndef TDATAENTRYBASE_HH
-#include "tDataEntryBase.hh"
-#endif
-
-class cString;
-
-template <class T, class OUT, class ARG> class tArgDataEntry
- : public tDataEntryBase<T> {
-protected:
- OUT (T::*DataRetrieval)(ARG) const;
- int (T::*DataCompare)(T*,ARG) const;
- ARG arg;
-public:
- tArgDataEntry(const cString & _name, const cString & _desc,
- OUT (T::*_funR)(ARG) const, ARG _arg,
- //int (T::*_funC)(T * _o, ARG _i) const = &T::CompareArgNULL,
- int (T::*_funC)(T * _o, ARG _i) const = 0,
- const cString & _null="0",
- const cString & _html_cell="align=center")
- : tDataEntryBase<T>(_name, _desc, _null, _html_cell),
- DataRetrieval(_funR), DataCompare(_funC), arg(_arg) { ; }
-
- bool Print(std::ostream & fp) const {
- if (this->target == NULL) return false;
- fp << (this->target->*DataRetrieval)(arg);
- return true;
- }
-
- //int Compare(T * other) const { return (target->*DataCompare)(other, arg); }
- int Compare(T * other) const {
- return (DataCompare)?((this->target->*DataCompare)(other, arg)):(0);
- }
-};
-
-#endif
Copied: trunk/source/tools/tArray.h (from rev 338, trunk/source/tools/tArray.hh)
===================================================================
--- trunk/source/tools/tArray.hh 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/tools/tArray.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -0,0 +1,175 @@
+//////////////////////////////////////////////////////////////////////////////
+// Copyright (C) 1993 - 2003 California Institute of Technology //
+// //
+// Read the COPYING and README files, or contact 'avida at alife.org', //
+// before continuing. SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE. //
+//////////////////////////////////////////////////////////////////////////////
+
+/*
+ tArray.h
+ Array Templates
+
+ Constructor:
+ tArray( int size )
+ tArray( const tArray & rhs )
+
+ Interface:
+ tArray & operator= ( const tArray & rhs )
+
+ bool Good () const
+ array is defined and ready to take data
+
+ unsigned int GetSize () const
+ returns the size of the array
+
+ const T& ElementAt ( const int index ) const
+ T& ElementAt ( const int index )
+ const T& operator[] ( const int index ) const
+ T& operator[] ( const int index )
+ return the element at index in the array
+*/
+
+#ifndef TARRAY_HH
+#define TARRAY_HH
+
+#include <assert.h>
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+/**
+ * This class provides an array template.
+ **/
+
+template <class T> class tArray {
+
+protected:
+ // Internal Variables
+ T * data; // Data Elements
+ int size; // Number of Elements
+
+public:
+ void ResizeClear(const int in_size){
+ size = in_size;
+ assert(size >= 0); // Invalid size specified for array intialization
+ if (data != NULL) delete [] data; // remove old data if exists
+ if (size > 0) {
+ data = new T[size]; // Allocate block for data
+ assert(data != NULL); // Memory allocation error: Out of Memory?
+ }
+ else data = NULL;
+ }
+
+public:
+ // Constructor
+ explicit tArray(const int _size=0) : data(NULL) {
+ ResizeClear(_size);
+ }
+
+ // Assingment Operator
+ tArray & operator= (const tArray & rhs) {
+ if (size != rhs.GetSize()) ResizeClear(rhs.GetSize());
+ for(int i = 0; i < size; i++) data[i] = rhs[i];
+ return *this;
+ }
+
+ // Copy constructor
+ //explicit tArray(const tArray & rhs) : data(NULL), size(0) {
+ // this->operator=(rhs);
+ //}
+
+ tArray(const tArray & rhs) : data(NULL), size(0) {
+ this->operator=(rhs);
+ }
+
+
+ // Destructor
+ virtual ~tArray() {
+ if (data != NULL) delete [] data;
+ }
+
+ // Interface Methods ///////////////////////////////////////////////////////
+
+ bool Good() const { return (data != NULL); }
+
+// bool OK() const {
+// assert(size >= 0);
+// return true;
+// }
+
+ int GetSize() const { return size; }
+
+ void Resize(int new_size) {
+ assert(new_size >= 0);
+
+ // If we're already at the size we want, don't bother doing anything.
+ if (size == new_size) return;
+
+ // If new size is 0, clean up and go!
+ if (new_size == 0) {
+ delete [] data;
+ data = NULL;
+ size = 0;
+ return;
+ }
+
+ // If new size > 0
+ T * new_data = new T[new_size];
+ assert(new_data != NULL); // Memory Allocation Error: Out of Memory?
+
+ // Copy over old data...
+ for (int i = 0; i < size && i < new_size; i++) {
+ new_data[i] = data[i];
+ }
+ if (data != NULL) delete [] data; // remove old data if exists
+ data = new_data;
+
+ size = new_size;
+ }
+
+
+ void Resize(int new_size, const T & empty_value) {
+ assert(new_size >= 0);
+ int old_size = size;
+ Resize(new_size);
+ if( new_size > old_size ){
+ for (int i = old_size; i < new_size; i++) {
+ data[i] = empty_value;
+ }
+ }
+ }
+
+
+ T & ElementAt(const int index){
+ // check range
+ assert(index >= 0); // Lower Bounds Error
+ assert(index < size); // Upper Bounds Error
+ return data[index]; // in range, so return element
+ }
+
+ const T & ElementAt(const int index) const {
+ // check range
+ assert(index >= 0); // Lower Bounds Error
+ assert(index < size); // Upper Bounds Error
+ return data[index]; // in range, so return element
+ }
+
+ T & operator[](const int index) { return ElementAt(index); }
+ const T & operator[](const int index) const { return ElementAt(index); }
+
+
+ void Push(const T & value) {
+ Resize(size+1);
+ data[size-1] = value;
+ }
+
+ void SetAll(const T & value){
+ for( int i=0; i < size; ++i ){
+ data[i] = value;
+ }
+ }
+
+};
+
+#endif // TARRAY_HH
Deleted: trunk/source/tools/tArray.hh
===================================================================
--- trunk/source/tools/tArray.hh 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/tools/tArray.hh 2005-10-10 23:44:52 UTC (rev 339)
@@ -1,175 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// Copyright (C) 1993 - 2003 California Institute of Technology //
-// //
-// Read the COPYING and README files, or contact 'avida at alife.org', //
-// before continuing. SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE. //
-//////////////////////////////////////////////////////////////////////////////
-
-/*
- tArray.hh
- Array Templates
-
- Constructor:
- tArray( int size )
- tArray( const tArray & rhs )
-
- Interface:
- tArray & operator= ( const tArray & rhs )
-
- bool Good () const
- array is defined and ready to take data
-
- unsigned int GetSize () const
- returns the size of the array
-
- const T& ElementAt ( const int index ) const
- T& ElementAt ( const int index )
- const T& operator[] ( const int index ) const
- T& operator[] ( const int index )
- return the element at index in the array
-*/
-
-#ifndef TARRAY_HH
-#define TARRAY_HH
-
-#include <assert.h>
-
-#ifndef NULL
-#define NULL 0
-#endif
-
-/**
- * This class provides an array template.
- **/
-
-template <class T> class tArray {
-
-protected:
- // Internal Variables
- T * data; // Data Elements
- int size; // Number of Elements
-
-public:
- void ResizeClear(const int in_size){
- size = in_size;
- assert(size >= 0); // Invalid size specified for array intialization
- if (data != NULL) delete [] data; // remove old data if exists
- if (size > 0) {
- data = new T[size]; // Allocate block for data
- assert(data != NULL); // Memory allocation error: Out of Memory?
- }
- else data = NULL;
- }
-
-public:
- // Constructor
- explicit tArray(const int _size=0) : data(NULL) {
- ResizeClear(_size);
- }
-
- // Assingment Operator
- tArray & operator= (const tArray & rhs) {
- if (size != rhs.GetSize()) ResizeClear(rhs.GetSize());
- for(int i = 0; i < size; i++) data[i] = rhs[i];
- return *this;
- }
-
- // Copy constructor
- //explicit tArray(const tArray & rhs) : data(NULL), size(0) {
- // this->operator=(rhs);
- //}
-
- tArray(const tArray & rhs) : data(NULL), size(0) {
- this->operator=(rhs);
- }
-
-
- // Destructor
- virtual ~tArray() {
- if (data != NULL) delete [] data;
- }
-
- // Interface Methods ///////////////////////////////////////////////////////
-
- bool Good() const { return (data != NULL); }
-
-// bool OK() const {
-// assert(size >= 0);
-// return true;
-// }
-
- int GetSize() const { return size; }
-
- void Resize(int new_size) {
- assert(new_size >= 0);
-
- // If we're already at the size we want, don't bother doing anything.
- if (size == new_size) return;
-
- // If new size is 0, clean up and go!
- if (new_size == 0) {
- delete [] data;
- data = NULL;
- size = 0;
- return;
- }
-
- // If new size > 0
- T * new_data = new T[new_size];
- assert(new_data != NULL); // Memory Allocation Error: Out of Memory?
-
- // Copy over old data...
- for (int i = 0; i < size && i < new_size; i++) {
- new_data[i] = data[i];
- }
- if (data != NULL) delete [] data; // remove old data if exists
- data = new_data;
-
- size = new_size;
- }
-
-
- void Resize(int new_size, const T & empty_value) {
- assert(new_size >= 0);
- int old_size = size;
- Resize(new_size);
- if( new_size > old_size ){
- for (int i = old_size; i < new_size; i++) {
- data[i] = empty_value;
- }
- }
- }
-
-
- T & ElementAt(const int index){
- // check range
- assert(index >= 0); // Lower Bounds Error
- assert(index < size); // Upper Bounds Error
- return data[index]; // in range, so return element
- }
-
- const T & ElementAt(const int index) const {
- // check range
- assert(index >= 0); // Lower Bounds Error
- assert(index < size); // Upper Bounds Error
- return data[index]; // in range, so return element
- }
-
- T & operator[](const int index) { return ElementAt(index); }
- const T & operator[](const int index) const { return ElementAt(index); }
-
-
- void Push(const T & value) {
- Resize(size+1);
- data[size-1] = value;
- }
-
- void SetAll(const T & value){
- for( int i=0; i < size; ++i ){
- data[i] = value;
- }
- }
-
-};
-
-#endif // TARRAY_HH
Copied: trunk/source/tools/tBuffer.h (from rev 338, trunk/source/tools/tBuffer.hh)
===================================================================
--- trunk/source/tools/tBuffer.hh 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/tools/tBuffer.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -0,0 +1,89 @@
+//////////////////////////////////////////////////////////////////////////////
+// Copyright (C) 1993 - 2003 California Institute of Technology //
+// //
+// Read the COPYING and README files, or contact 'avida at alife.org', //
+// before continuing. SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE. //
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef TBUFFER_HH
+#define TBUFFER_HH
+
+#include <assert.h>
+#include <iostream>
+
+#ifndef STRING_HH
+#include "cString.h"
+#endif
+#ifndef TARRAY_HH
+#include "tArray.h"
+#endif
+
+template <class T> class tArray; // aggregate
+class cString; // aggregate
+
+template <class T> class tBuffer {
+private:
+ tArray<T> data; // Contents of buffer...
+ int offset; // Position in buffer to next write.
+ int total; // Total inputs ever...
+ int last_total; // Total inputs at time of last ZeroNumAdds.
+public:
+ tBuffer(const int size) : data(size), offset(0), total(0),
+ last_total(0) { ; }
+ tBuffer(const tBuffer<T> & in) : data(in.data), offset(in.offset),
+ total(in.total), last_total(in.last_total) { ; }
+
+ tBuffer & operator= (const tBuffer<T> & in) {
+ data = in.data;
+ offset = in.offset;
+ total = in.total;
+ last_total = in.last_total;
+ return *this;
+ }
+
+ ~tBuffer() { ; }
+
+ void Clear() { offset = 0; total = 0; last_total = 0; }
+
+ void Add(T in){
+ data[offset] = in;
+ total++;
+ offset++;
+ while (offset >= data.GetSize()) offset -= data.GetSize();
+ }
+
+ void ZeroNumAdds() { total = 0; }
+
+ T operator[] (int i) const {
+ int index = offset - i - 1;
+ while (index < 0) index += data.GetSize();
+ return data[index];
+ }
+
+ int GetCapacity() const { return data.GetSize(); }
+ int GetTotal() const { return total; }
+ int GetNumStored() const
+ { return (total <= data.GetSize()) ? total : data.GetSize(); }
+ int GetNum() const { return total - last_total; }
+
+ void SaveState(std::ostream & fp) {
+ assert(fp.good());
+ fp << "tBuffer" << " ";
+ fp << data.GetSize() << " ";
+ for (int i = 0; i < data.GetSize(); i++) fp << data[i] << " ";
+ fp << offset << " " << total << " " << last_total << " " << std::endl;
+ }
+
+ void LoadState(std::istream & fp) {
+ assert(fp.good());
+ cString foo; fp >> foo; assert(foo == "tBuffer");
+ int capacity; fp >> capacity;
+ data.Resize(capacity);
+ for (int i = 0; i < capacity; i++) {
+ fp >> data[i];
+ }
+ fp >> offset >> total >> last_total;
+ }
+};
+
+#endif
Deleted: trunk/source/tools/tBuffer.hh
===================================================================
--- trunk/source/tools/tBuffer.hh 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/tools/tBuffer.hh 2005-10-10 23:44:52 UTC (rev 339)
@@ -1,89 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// Copyright (C) 1993 - 2003 California Institute of Technology //
-// //
-// Read the COPYING and README files, or contact 'avida at alife.org', //
-// before continuing. SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE. //
-//////////////////////////////////////////////////////////////////////////////
-
-#ifndef TBUFFER_HH
-#define TBUFFER_HH
-
-#include <assert.h>
-#include <iostream>
-
-#ifndef STRING_HH
-#include "cString.h"
-#endif
-#ifndef TARRAY_HH
-#include "tArray.hh"
-#endif
-
-template <class T> class tArray; // aggregate
-class cString; // aggregate
-
-template <class T> class tBuffer {
-private:
- tArray<T> data; // Contents of buffer...
- int offset; // Position in buffer to next write.
- int total; // Total inputs ever...
- int last_total; // Total inputs at time of last ZeroNumAdds.
-public:
- tBuffer(const int size) : data(size), offset(0), total(0),
- last_total(0) { ; }
- tBuffer(const tBuffer<T> & in) : data(in.data), offset(in.offset),
- total(in.total), last_total(in.last_total) { ; }
-
- tBuffer & operator= (const tBuffer<T> & in) {
- data = in.data;
- offset = in.offset;
- total = in.total;
- last_total = in.last_total;
- return *this;
- }
-
- ~tBuffer() { ; }
-
- void Clear() { offset = 0; total = 0; last_total = 0; }
-
- void Add(T in){
- data[offset] = in;
- total++;
- offset++;
- while (offset >= data.GetSize()) offset -= data.GetSize();
- }
-
- void ZeroNumAdds() { total = 0; }
-
- T operator[] (int i) const {
- int index = offset - i - 1;
- while (index < 0) index += data.GetSize();
- return data[index];
- }
-
- int GetCapacity() const { return data.GetSize(); }
- int GetTotal() const { return total; }
- int GetNumStored() const
- { return (total <= data.GetSize()) ? total : data.GetSize(); }
- int GetNum() const { return total - last_total; }
-
- void SaveState(std::ostream & fp) {
- assert(fp.good());
- fp << "tBuffer" << " ";
- fp << data.GetSize() << " ";
- for (int i = 0; i < data.GetSize(); i++) fp << data[i] << " ";
- fp << offset << " " << total << " " << last_total << " " << std::endl;
- }
-
- void LoadState(std::istream & fp) {
- assert(fp.good());
- cString foo; fp >> foo; assert(foo == "tBuffer");
- int capacity; fp >> capacity;
- data.Resize(capacity);
- for (int i = 0; i < capacity; i++) {
- fp >> data[i];
- }
- fp >> offset >> total >> last_total;
- }
-};
-
-#endif
Copied: trunk/source/tools/tDataEntry.h (from rev 338, trunk/source/tools/tDataEntry.hh)
===================================================================
--- trunk/source/tools/tDataEntry.hh 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/tools/tDataEntry.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -0,0 +1,62 @@
+//////////////////////////////////////////////////////////////////////////////
+// Copyright (C) 1993 - 2003 California Institute of Technology //
+// //
+// Read the COPYING and README files, or contact 'avida at alife.org', //
+// before continuing. SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE. //
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef TDATAENTRY_HH
+#define TDATAENTRY_HH
+
+#include <iostream>
+
+#ifndef STRING_HH
+#include "cString.h"
+#endif
+#ifndef STRING_UTIL_HH
+#include "cStringUtil.h"
+#endif
+#ifndef TDATAENTRYBASE_HH
+#include "tDataEntryBase.h"
+#endif
+
+class cString;
+struct cStringUtil; // access
+
+template <class T, class OUT> class tDataEntry : public tDataEntryBase<T> {
+protected:
+ OUT (T::*DataRetrieval)() const;
+ void (T::*DataSet)(OUT);
+ int (T::*DataCompare)(T*) const;
+
+ int CmpNULL(T *) const { return 0; }
+public:
+ tDataEntry(const cString & _name, const cString & _desc,
+ OUT (T::*_funR)() const,
+ void (T::*_funS)(OUT _val) = NULL,
+ //int (T::*_funC)(T * _o) const = &T::CompareNULL,
+ int (T::*_funC)(T * _o) const = 0,
+ const cString & _null="0",
+ const cString & _html_cell="align=center")
+ : tDataEntryBase<T>(_name, _desc, _null, _html_cell), DataRetrieval(_funR),
+ DataSet(_funS), DataCompare(_funC) { ; }
+
+ bool Print(std::ostream & fp) const {
+ if (this->target == NULL) return false;
+ fp << (this->target->*DataRetrieval)();
+ return true;
+ }
+
+ //int Compare(T * other) const { return (target->*DataCompare)(other); }
+ int Compare(T * other) const {
+ return (DataCompare)?((this->target->*DataCompare)(other)):(0);
+ }
+ bool Set(const cString & value) {
+ OUT new_value(0);
+ if (DataSet == 0) return false;
+ (this->target->*DataSet)( cStringUtil::Convert(value, new_value) );
+ return true;
+ }
+};
+
+#endif
Deleted: trunk/source/tools/tDataEntry.hh
===================================================================
--- trunk/source/tools/tDataEntry.hh 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/tools/tDataEntry.hh 2005-10-10 23:44:52 UTC (rev 339)
@@ -1,62 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// Copyright (C) 1993 - 2003 California Institute of Technology //
-// //
-// Read the COPYING and README files, or contact 'avida at alife.org', //
-// before continuing. SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE. //
-//////////////////////////////////////////////////////////////////////////////
-
-#ifndef TDATAENTRY_HH
-#define TDATAENTRY_HH
-
-#include <iostream>
-
-#ifndef STRING_HH
-#include "cString.h"
-#endif
-#ifndef STRING_UTIL_HH
-#include "cStringUtil.h"
-#endif
-#ifndef TDATAENTRYBASE_HH
-#include "tDataEntryBase.hh"
-#endif
-
-class cString;
-struct cStringUtil; // access
-
-template <class T, class OUT> class tDataEntry : public tDataEntryBase<T> {
-protected:
- OUT (T::*DataRetrieval)() const;
- void (T::*DataSet)(OUT);
- int (T::*DataCompare)(T*) const;
-
- int CmpNULL(T *) const { return 0; }
-public:
- tDataEntry(const cString & _name, const cString & _desc,
- OUT (T::*_funR)() const,
- void (T::*_funS)(OUT _val) = NULL,
- //int (T::*_funC)(T * _o) const = &T::CompareNULL,
- int (T::*_funC)(T * _o) const = 0,
- const cString & _null="0",
- const cString & _html_cell="align=center")
- : tDataEntryBase<T>(_name, _desc, _null, _html_cell), DataRetrieval(_funR),
- DataSet(_funS), DataCompare(_funC) { ; }
-
- bool Print(std::ostream & fp) const {
- if (this->target == NULL) return false;
- fp << (this->target->*DataRetrieval)();
- return true;
- }
-
- //int Compare(T * other) const { return (target->*DataCompare)(other); }
- int Compare(T * other) const {
- return (DataCompare)?((this->target->*DataCompare)(other)):(0);
- }
- bool Set(const cString & value) {
- OUT new_value(0);
- if (DataSet == 0) return false;
- (this->target->*DataSet)( cStringUtil::Convert(value, new_value) );
- return true;
- }
-};
-
-#endif
Copied: trunk/source/tools/tDataEntryBase.h (from rev 338, trunk/source/tools/tDataEntryBase.hh)
Deleted: trunk/source/tools/tDataEntryBase.hh
===================================================================
--- trunk/source/tools/tDataEntryBase.hh 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/tools/tDataEntryBase.hh 2005-10-10 23:44:52 UTC (rev 339)
@@ -1,68 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// Copyright (C) 1993 - 2003 California Institute of Technology //
-// //
-// Read the COPYING and README files, or contact 'avida at alife.org', //
-// before continuing. SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE. //
-//////////////////////////////////////////////////////////////////////////////
-
-#ifndef TDATAENTRYBASE_HH
-#define TDATAENTRYBASE_HH
-
-#include <iostream>
-#include <sstream>
-
-#ifndef DATA_ENTRY_HH
-#include "cDataEntry.h"
-#endif
-
-using namespace std;
-
-class cString;
-
-template <class T> class tDataEntryBase : public cDataEntry {
-protected:
- T * target;
-public:
- tDataEntryBase(const cString & _name, const cString & _desc,
- const cString & _null="0",
- const cString & _html_cell="align=center")
- : cDataEntry(_name, _desc, _null, _html_cell), target(NULL) { ; }
-
- void SetTarget(T * _target) { target = _target; }
-
- virtual bool Print(std::ostream & fp) const { (void) fp; return false; }
- virtual int Compare(T * other) const { (void) other; return 0; }
- virtual bool Set(const cString & value) { (void) value; return false; }
-
- void HTMLPrint(std::ostream & fp, int compare=0, bool print_text=true) {
- fp << "<td " << GetHtmlCellFlags() << " ";
- if (compare == -2) {
- fp << "bgcolor=\"#FF0000\">";
- if (print_text == true) fp << GetNull() << " ";
- else fp << " ";
- return;
- }
-
- if (compare == -1) fp << "bgcolor=\"#FFCCCC\">";
- else if (compare == 0) fp << ">";
- else if (compare == 1) fp << "bgcolor=\"#CCFFCC\">";
- else if (compare == 2) fp << "bgcolor=\"#00FF00\">";
- else {
- std::cerr << "Error! Illegal case in Compare:" << compare << std::endl;
- exit(0);
- }
-
- if (print_text == true) fp << *this << " ";
- else fp << " ";
- }
-
- cString AsString() {
- stringstream tmp_stream;
- tmp_stream << *this;
- cString out_str;
- tmp_stream >> out_str;
- return out_str;
- }
-};
-
-#endif
Copied: trunk/source/tools/tDataEntryCommand.h (from rev 338, trunk/source/tools/tDataEntryCommand.hh)
===================================================================
--- trunk/source/tools/tDataEntryCommand.hh 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/tools/tDataEntryCommand.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -0,0 +1,50 @@
+//////////////////////////////////////////////////////////////////////////////
+// Copyright (C) 1993 - 2003 California Institute of Technology //
+// //
+// Read the COPYING and README files, or contact 'avida at alife.org', //
+// before continuing. SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE. //
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef TDATAENTRYCOMMAND_HH
+#define TDATAENTRYCOMMAND_HH
+
+#include <iostream>
+
+#ifndef STRING_LIST_HH
+#include "cStringList.h"
+#endif
+#ifndef TDATAENTRYBASE_HH
+#include "tDataEntryBase.h"
+#endif
+
+class cString;
+class cStringList; // aggregate
+template <class T> class tDataEntryBase; // access
+
+template <class T> class tDataEntryCommand {
+private:
+ tDataEntryBase<T> * data_entry;
+ cStringList args;
+public:
+ tDataEntryCommand(tDataEntryBase<T> * _entry, const cString & _args="")
+ : data_entry(_entry), args(_args, ':') { ; }
+
+ tDataEntryBase<T> & GetEntry() { return *data_entry; }
+ const cStringList & GetArgs() const { return args; }
+ bool HasArg(const cString & test_arg) { return args.HasString(test_arg); }
+
+ const cString & GetName() const { return data_entry->GetName(); }
+ const cString & GetDesc() const { return data_entry->GetDesc(); }
+ const cString & GetNull() const { return data_entry->GetNull(); }
+ const cString & GetHtmlCellFlags() const
+ { return data_entry->GetHtmlCellFlags(); }
+
+ void SetTarget(T * _target) { data_entry->SetTarget(_target); }
+ bool Print(std::ostream & fp) const { return data_entry->Print(fp); }
+ int Compare(T * other) const { return data_entry->Compare(other); }
+ bool SetValue(const cString & value) { return data_entry->Set(value); }
+ void HTMLPrint(std::ostream & fp, int compare=0, bool print_text=true)
+ { data_entry->HTMLPrint(fp, compare, print_text); }
+};
+
+#endif
Deleted: trunk/source/tools/tDataEntryCommand.hh
===================================================================
--- trunk/source/tools/tDataEntryCommand.hh 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/tools/tDataEntryCommand.hh 2005-10-10 23:44:52 UTC (rev 339)
@@ -1,50 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// Copyright (C) 1993 - 2003 California Institute of Technology //
-// //
-// Read the COPYING and README files, or contact 'avida at alife.org', //
-// before continuing. SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE. //
-//////////////////////////////////////////////////////////////////////////////
-
-#ifndef TDATAENTRYCOMMAND_HH
-#define TDATAENTRYCOMMAND_HH
-
-#include <iostream>
-
-#ifndef STRING_LIST_HH
-#include "cStringList.h"
-#endif
-#ifndef TDATAENTRYBASE_HH
-#include "tDataEntryBase.hh"
-#endif
-
-class cString;
-class cStringList; // aggregate
-template <class T> class tDataEntryBase; // access
-
-template <class T> class tDataEntryCommand {
-private:
- tDataEntryBase<T> * data_entry;
- cStringList args;
-public:
- tDataEntryCommand(tDataEntryBase<T> * _entry, const cString & _args="")
- : data_entry(_entry), args(_args, ':') { ; }
-
- tDataEntryBase<T> & GetEntry() { return *data_entry; }
- const cStringList & GetArgs() const { return args; }
- bool HasArg(const cString & test_arg) { return args.HasString(test_arg); }
-
- const cString & GetName() const { return data_entry->GetName(); }
- const cString & GetDesc() const { return data_entry->GetDesc(); }
- const cString & GetNull() const { return data_entry->GetNull(); }
- const cString & GetHtmlCellFlags() const
- { return data_entry->GetHtmlCellFlags(); }
-
- void SetTarget(T * _target) { data_entry->SetTarget(_target); }
- bool Print(std::ostream & fp) const { return data_entry->Print(fp); }
- int Compare(T * other) const { return data_entry->Compare(other); }
- bool SetValue(const cString & value) { return data_entry->Set(value); }
- void HTMLPrint(std::ostream & fp, int compare=0, bool print_text=true)
- { data_entry->HTMLPrint(fp, compare, print_text); }
-};
-
-#endif
Copied: trunk/source/tools/tDataManager.h (from rev 338, trunk/source/tools/tDataManager.hh)
===================================================================
--- trunk/source/tools/tDataManager.hh 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/tools/tDataManager.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -0,0 +1,70 @@
+//////////////////////////////////////////////////////////////////////////////
+// Copyright (C) 1993 - 2003 California Institute of Technology //
+// //
+// Read the COPYING and README files, or contact 'avida at alife.org', //
+// before continuing. SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE. //
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef TDATAMANAGER_HH
+#define TDATAMANAGER_HH
+
+#include <iostream>
+
+#ifndef DATA_MANAGER_BASE_HH
+#include "cDataManager_Base.h"
+#endif
+#ifndef TDATAENTRYBASE_HH
+#include "tDataEntryBase.h"
+#endif
+#ifndef TDICTIONARY_HH
+#include "tDictionary.h"
+#endif
+
+// This template manages a collection of keywords and associates each with
+// an accessor for a specific object. When a list of keywords is then
+// fed in with an output file, the associated data for that object will
+// then be printed to the output file.
+
+class cString;
+template <class T, class U> class tDataEntry;
+template <class T> class tDataEntryBase; // access
+template <class T> class tDictionary; // aggregate
+
+template <class T> class tDataManager : public cDataManager_Base {
+private:
+ T * target;
+ tDictionary< tDataEntryBase<T> * > entry_dict;
+public:
+ tDataManager(T * _target, const cString & in_filetype="unknown")
+ : cDataManager_Base(in_filetype), target(_target) { ; }
+ ~tDataManager() { ; }
+
+ template<class OUT> bool Add(const cString & name, const cString & desc,
+ OUT (T::*_funR)() const,
+ void (T::*_funS)(OUT _val) = NULL,
+ int (T::*_funC)(T * _o) const = NULL,
+ const cString & null="0",
+ const cString & html_cell="align=center") {
+ tDataEntryBase<T> * new_entry =
+ new tDataEntry<T, OUT> (name, desc, _funR, _funS, _funC, null, html_cell);
+ new_entry->SetTarget(target);
+ entry_dict.Add(name, new_entry);
+ return true;
+ }
+
+ bool Print(const cString & name, std::ostream & fp) {
+ tDataEntryBase<T> * cur_entry = NULL;
+ if (entry_dict.Find(name, cur_entry) == false) return false;
+ cur_entry->Print(fp);
+ return true;
+ }
+
+ bool GetDesc(const cString & name, cString & out_desc) {
+ tDataEntryBase<T> * cur_entry = NULL;
+ if (entry_dict.Find(name, cur_entry) == false) return false;
+ out_desc = cur_entry->GetDesc();
+ return true;
+ }
+};
+
+#endif
Deleted: trunk/source/tools/tDataManager.hh
===================================================================
--- trunk/source/tools/tDataManager.hh 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/tools/tDataManager.hh 2005-10-10 23:44:52 UTC (rev 339)
@@ -1,70 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// Copyright (C) 1993 - 2003 California Institute of Technology //
-// //
-// Read the COPYING and README files, or contact 'avida at alife.org', //
-// before continuing. SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE. //
-//////////////////////////////////////////////////////////////////////////////
-
-#ifndef TDATAMANAGER_HH
-#define TDATAMANAGER_HH
-
-#include <iostream>
-
-#ifndef DATA_MANAGER_BASE_HH
-#include "cDataManager_Base.h"
-#endif
-#ifndef TDATAENTRYBASE_HH
-#include "tDataEntryBase.hh"
-#endif
-#ifndef TDICTIONARY_HH
-#include "tDictionary.hh"
-#endif
-
-// This template manages a collection of keywords and associates each with
-// an accessor for a specific object. When a list of keywords is then
-// fed in with an output file, the associated data for that object will
-// then be printed to the output file.
-
-class cString;
-template <class T, class U> class tDataEntry;
-template <class T> class tDataEntryBase; // access
-template <class T> class tDictionary; // aggregate
-
-template <class T> class tDataManager : public cDataManager_Base {
-private:
- T * target;
- tDictionary< tDataEntryBase<T> * > entry_dict;
-public:
- tDataManager(T * _target, const cString & in_filetype="unknown")
- : cDataManager_Base(in_filetype), target(_target) { ; }
- ~tDataManager() { ; }
-
- template<class OUT> bool Add(const cString & name, const cString & desc,
- OUT (T::*_funR)() const,
- void (T::*_funS)(OUT _val) = NULL,
- int (T::*_funC)(T * _o) const = NULL,
- const cString & null="0",
- const cString & html_cell="align=center") {
- tDataEntryBase<T> * new_entry =
- new tDataEntry<T, OUT> (name, desc, _funR, _funS, _funC, null, html_cell);
- new_entry->SetTarget(target);
- entry_dict.Add(name, new_entry);
- return true;
- }
-
- bool Print(const cString & name, std::ostream & fp) {
- tDataEntryBase<T> * cur_entry = NULL;
- if (entry_dict.Find(name, cur_entry) == false) return false;
- cur_entry->Print(fp);
- return true;
- }
-
- bool GetDesc(const cString & name, cString & out_desc) {
- tDataEntryBase<T> * cur_entry = NULL;
- if (entry_dict.Find(name, cur_entry) == false) return false;
- out_desc = cur_entry->GetDesc();
- return true;
- }
-};
-
-#endif
Copied: trunk/source/tools/tDictionary.h (from rev 338, trunk/source/tools/tDictionary.hh)
===================================================================
--- trunk/source/tools/tDictionary.hh 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/tools/tDictionary.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -0,0 +1,327 @@
+//////////////////////////////////////////////////////////////////////////////
+// Copyright (C) 1993 - 2005 California Institute of Technology //
+// //
+// Read the COPYING and README files, or contact 'avida at alife.org', //
+// before continuing. SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE. //
+//////////////////////////////////////////////////////////////////////////////
+
+/*
+ * This template is used to look up objects of the desired type by name.
+ * I is implemented through use of a linked list and a hash table. The linked
+ * list contains all of the individual entries stored in the dictionary (in an
+ * arbitrary order). The hash table points to the first entry in the list
+ * that fits in its cell. If there are no entries that fit in the cell, the
+ * has table contains a NULL pointer at that location.
+ *
+ * INTERFACE:
+ * tDictionary(int in_hash_size=DICTIONARY_HASH_DEFAULT) // Constructor
+ * ~tDictionary() // Destructor
+ * int GetSize() // Get dictionary size
+ * void Add(const cString & name, T data) // Add new entry
+ * bool HasEntry(const cString & name) // Test if key exists
+ * bool Find(const cString & name, T & out_data) // Find entry for key
+ * T Remove(const cString & name) // Remove entry
+ * cString NearMatch(const cString name) // Find closest key
+ * void SetHash(int _hash) // Change hash table size
+ *
+ *
+ * IMPLEMENTATION NOTES:
+ *
+ * On INSERT: If a cell already has at least one entry in it, the new entry
+ * gets inserted into the linked list before the existing entry. If the cell
+ * is currently empty, the new entry gets placed at the end of the linked
+ * list. In either case, the cell is updated to point at the new entry.
+ *
+ * On DELETE: Start looking at the position in the list where the cell is
+ * pointing and continue until the entry-to-be-deleted is found. If the
+ * entry to be deleted is the one being pointed at, be sure to update the
+ * cell.
+ *
+ * On LOOKUP: If the cell has a NULL pointer, lookup fails. Otherwise search
+ * through list until either correct entry is found (lookup succeeds) or else
+ * the lookup finds an entry not in the current cell (lookup fails).
+ */
+
+#ifndef TDICTIONARY_HH
+#define TDICTIONARY_HH
+
+#ifndef STRING_HH
+#include "cString.h"
+#endif
+#ifndef STRING_UTIL_HH
+#include "cStringUtil.h"
+#endif
+#ifndef TARRAY_HH
+#include "tArray.h"
+#endif
+#ifndef TLIST_HH
+#include "tList.h"
+#endif
+
+#define DICTIONARY_HASH_DEFAULT 23
+#define DICTIONARY_HASH_MEDIUM 331
+#define DICTIONARY_HASH_LARGE 2311
+
+class cString; // aggregate
+struct cStringUtil; // access
+template <class T> class tList; // access
+template <class T> class tListIterator; // aggregate
+
+template <class T> class tDictionary {
+
+ // We create a structure with full information about each entry stored in
+ // this dictionary.
+ template <class U> struct tDictEntry {
+ cString name;
+ int id;
+ U data;
+ };
+
+private:
+ int dict_size; // How many entries are we storing?
+ int hash_size; // What size hash table are we using?
+
+ tList< tDictEntry<T> > entry_list; // A linked list of ALL entries
+ tArray< tListNode< tDictEntry<T> > * > cell_array; // Pointers to the entry list.
+ tListIterator< tDictEntry<T> > list_it; // Iterator for entry_list
+
+ // Currently, we hash a string simply by adding up the individual character
+ // values in that string and modding by the hash size. For most applications
+ // this will work fine (and it is fast!) but some patters will cause all
+ // strings to go into the same cell. For example, "ABC"=="CBA"=="BBB".
+ int HashString(const cString & key) const {
+ unsigned int out_hash = 0;
+ for (int i = 0; i < key.GetSize(); i++)
+ out_hash += (unsigned int) key[i];
+ return out_hash % hash_size;
+ }
+
+ // Function to find the appropriate tDictEntry for a string that is passed
+ // in and return it.
+ tDictEntry<T> * FindEntry(const cString & name) {
+ const int bin = HashString(name);
+ if (cell_array[bin] == NULL) return NULL;
+
+ // Set the list iterator to the first entry of this bin.
+ list_it.Set(cell_array[bin]);
+
+ // Loop through all entries in this bin to see if any are a perfect match.
+ while (list_it.Get() != NULL && list_it.Get()->id == bin) {
+ if (list_it.Get()->name == name) return list_it.Get();
+ list_it.Next();
+ }
+
+ // No matches found.
+ return NULL;
+ }
+private:
+ // disabled copy constructor.
+ tDictionary(const tDictionary &);
+public:
+ tDictionary(int in_hash_size=DICTIONARY_HASH_DEFAULT)
+ : dict_size(0)
+ , hash_size(in_hash_size)
+ , cell_array(in_hash_size)
+ , list_it(entry_list)
+ {
+ cell_array.SetAll(NULL);
+ }
+
+ ~tDictionary() {
+ while (entry_list.GetSize()) delete entry_list.Pop();
+ }
+
+
+ bool OK() {
+ std::cout << "DICT_SIZE = " << dict_size << std::endl;
+ std::cout << "HASH_SIZE = " << hash_size << std::endl;
+ int count = 0;
+ std::cout << "LIST ELEMENTS:" << std::endl;
+ list_it.Reset();
+ while (list_it.Next() != NULL) {
+ tDictEntry<T> * cur_entry = list_it.Get();
+ std::cout << " " << count << " : "
+ << cur_entry->id << " "
+ << cur_entry->name << " "
+ << cur_entry->data << " "
+ << std::endl;
+ }
+ std::cout << std::endl;
+ std::cout << "ARRAY CELLS: "
+ << cell_array.GetSize()
+ << std::endl;
+ for (int i = 0; i < hash_size; i++) {
+ tListNode< tDictEntry<T> > * cur_list_node = cell_array[i];
+ if (cur_list_node == NULL) {
+ std::cout << " NULL" << std::endl;
+ } else {
+ std::cout << " " << cur_list_node->data->id
+ << " " << cur_list_node->data->name
+ << std::endl;
+ }
+ }
+
+ return true;
+ }
+
+ int GetSize() { return dict_size; }
+
+ // This function is used to add a new entry...
+ void Add(const cString & name, T data) {
+ // Build the new entry...
+ tDictEntry<T> * new_entry = new tDictEntry<T>;
+ new_entry->name = name;
+ new_entry->data = data;
+ const int bin = HashString(name);
+ new_entry->id = bin;
+
+
+ // Determine where this new entry should go; either at the end of
+ // the list (if there are no others in the bin) or following another
+ // entry in the bin.
+ if (cell_array[bin] == NULL) { list_it.Reset(); } // Reset to list start
+ else { list_it.Set(cell_array[bin]); } // Else find insert point
+
+ entry_list.Insert(list_it, new_entry); // Place new entry in the list
+ list_it.Prev(); // Back up to new entry
+ cell_array[bin] = list_it.GetPos(); // Record position
+
+ // Update our entry count...
+ dict_size++;
+ }
+
+
+ // This function will change the value of an entry that exists, or add it
+ // if it doesn't exist.
+ void SetValue(const cString & name, T data) {
+ tDictEntry<T> * cur_entry = FindEntry(name);
+ if (cur_entry == NULL) {
+ Add(name, data);
+ return;
+ }
+ cur_entry->data = data;
+ }
+
+
+ bool HasEntry(const cString & name) {
+ return FindEntry(name) != NULL;
+ }
+
+ bool Find(const cString & name, T & out_data) {
+ tDictEntry<T> * found_entry = FindEntry(name);
+ if (found_entry != NULL) {
+ out_data = found_entry->data;
+ return true;
+ }
+ return false;
+ }
+
+ T Remove(const cString & name) {
+ // Determine the bin that we are going to be using.
+ const int bin = HashString(name);
+
+ T out_data;
+ assert(cell_array[bin] != NULL);
+ list_it.Set(cell_array[bin]);
+
+ // If we are deleting the first entry in this bin we must clean up...
+ if (list_it.Get()->name == name) {
+ out_data = list_it.Get()->data;
+ delete list_it.Remove();
+ list_it.Next();
+ dict_size--;
+ // See if the next entry is still part of this cell.
+ if (list_it.AtRoot() == false && list_it.Get()->id == bin) {
+ cell_array[bin] = list_it.GetPos();
+ } else {
+ cell_array[bin] = NULL;
+ }
+ }
+
+ // If it was not the first entry in this cell, keep looking!
+ else {
+ while (list_it.Next() != NULL && list_it.Get()->id == bin) {
+ if (list_it.Get()->name == name) {
+ out_data = list_it.Get()->data;
+ delete list_it.Remove();
+ dict_size--;
+ break;
+ }
+ }
+ }
+
+ return out_data;
+ }
+
+ cString NearMatch(const cString name) {
+ cString best_match("");
+ int best_dist = name.GetSize();
+ list_it.Reset();
+ while (list_it.Next() != NULL) {
+ int dist = cStringUtil::EditDistance(name, list_it.Get()->name);
+ if (dist < best_dist) {
+ best_dist = dist;
+ best_match = list_it.Get()->name;
+ }
+ }
+ return best_match;
+ }
+
+ void SetHash(int _hash) {
+ // Create the new table...
+ hash_size = _hash;
+ cell_array.ResizeClear(hash_size);
+ cell_array.SetAll(NULL);
+
+ // Backup all of the entries in the list and re-insert them one-by-one.
+ tList< tDictEntry<T> > backup_list;
+ backup_list.Transfer(entry_list);
+
+ while (backup_list.GetSize() > 0) {
+ tDictEntry<T> * cur_entry = backup_list.Pop();
+
+ // determine the new bin for this entry.
+ int bin = HashString(cur_entry->name);
+ cur_entry->id = bin;
+
+ if (cell_array[bin] == NULL) { list_it.Reset(); } // Reset to list start
+ else { list_it.Set(cell_array[bin]); } // Else find insert point
+
+ entry_list.Insert(list_it, cur_entry); // Place new entry in the list
+ list_it.Prev(); // Back up to new entry
+ cell_array[bin] = list_it.GetPos(); // Record position
+ }
+ }
+
+ // The following method allows the user to convert the dictionary contents
+ // into lists. Empty lists show be passed in as arguments and the method
+ // will fill in their contents.
+ void AsLists(tList<cString> & name_list, tList<T> & value_list) {
+ // Setup the lists to fill in.
+ assert(name_list.GetSize() == 0);
+ assert(value_list.GetSize() == 0);
+ tListIterator<cString> name_it(name_list);
+ tListIterator<T> value_it(value_list);
+
+ // Loop through the current entries and included them into the output
+ // list one at a time.
+ list_it.Reset();
+ while (list_it.Next() != NULL) {
+ // Grab the info about the current entry.
+ cString & cur_name = list_it.Get()->name;
+ T & cur_value = list_it.Get()->data;
+
+ // Find the position to place this in the lists.
+ name_it.Reset();
+ value_it.Reset();
+ value_it.Next();
+ while (name_it.Next() != NULL && cur_name > *(name_it.Get())) {
+ value_it.Next();
+ }
+ name_list.Insert(name_it, &cur_name);
+ value_list.Insert(value_it, &cur_value);
+ }
+ }
+};
+
+#endif
Deleted: trunk/source/tools/tDictionary.hh
===================================================================
--- trunk/source/tools/tDictionary.hh 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/tools/tDictionary.hh 2005-10-10 23:44:52 UTC (rev 339)
@@ -1,327 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// Copyright (C) 1993 - 2005 California Institute of Technology //
-// //
-// Read the COPYING and README files, or contact 'avida at alife.org', //
-// before continuing. SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE. //
-//////////////////////////////////////////////////////////////////////////////
-
-/*
- * This template is used to look up objects of the desired type by name.
- * I is implemented through use of a linked list and a hash table. The linked
- * list contains all of the individual entries stored in the dictionary (in an
- * arbitrary order). The hash table points to the first entry in the list
- * that fits in its cell. If there are no entries that fit in the cell, the
- * has table contains a NULL pointer at that location.
- *
- * INTERFACE:
- * tDictionary(int in_hash_size=DICTIONARY_HASH_DEFAULT) // Constructor
- * ~tDictionary() // Destructor
- * int GetSize() // Get dictionary size
- * void Add(const cString & name, T data) // Add new entry
- * bool HasEntry(const cString & name) // Test if key exists
- * bool Find(const cString & name, T & out_data) // Find entry for key
- * T Remove(const cString & name) // Remove entry
- * cString NearMatch(const cString name) // Find closest key
- * void SetHash(int _hash) // Change hash table size
- *
- *
- * IMPLEMENTATION NOTES:
- *
- * On INSERT: If a cell already has at least one entry in it, the new entry
- * gets inserted into the linked list before the existing entry. If the cell
- * is currently empty, the new entry gets placed at the end of the linked
- * list. In either case, the cell is updated to point at the new entry.
- *
- * On DELETE: Start looking at the position in the list where the cell is
- * pointing and continue until the entry-to-be-deleted is found. If the
- * entry to be deleted is the one being pointed at, be sure to update the
- * cell.
- *
- * On LOOKUP: If the cell has a NULL pointer, lookup fails. Otherwise search
- * through list until either correct entry is found (lookup succeeds) or else
- * the lookup finds an entry not in the current cell (lookup fails).
- */
-
-#ifndef TDICTIONARY_HH
-#define TDICTIONARY_HH
-
-#ifndef STRING_HH
-#include "cString.h"
-#endif
-#ifndef STRING_UTIL_HH
-#include "cStringUtil.h"
-#endif
-#ifndef TARRAY_HH
-#include "tArray.hh"
-#endif
-#ifndef TLIST_HH
-#include "tList.hh"
-#endif
-
-#define DICTIONARY_HASH_DEFAULT 23
-#define DICTIONARY_HASH_MEDIUM 331
-#define DICTIONARY_HASH_LARGE 2311
-
-class cString; // aggregate
-struct cStringUtil; // access
-template <class T> class tList; // access
-template <class T> class tListIterator; // aggregate
-
-template <class T> class tDictionary {
-
- // We create a structure with full information about each entry stored in
- // this dictionary.
- template <class U> struct tDictEntry {
- cString name;
- int id;
- U data;
- };
-
-private:
- int dict_size; // How many entries are we storing?
- int hash_size; // What size hash table are we using?
-
- tList< tDictEntry<T> > entry_list; // A linked list of ALL entries
- tArray< tListNode< tDictEntry<T> > * > cell_array; // Pointers to the entry list.
- tListIterator< tDictEntry<T> > list_it; // Iterator for entry_list
-
- // Currently, we hash a string simply by adding up the individual character
- // values in that string and modding by the hash size. For most applications
- // this will work fine (and it is fast!) but some patters will cause all
- // strings to go into the same cell. For example, "ABC"=="CBA"=="BBB".
- int HashString(const cString & key) const {
- unsigned int out_hash = 0;
- for (int i = 0; i < key.GetSize(); i++)
- out_hash += (unsigned int) key[i];
- return out_hash % hash_size;
- }
-
- // Function to find the appropriate tDictEntry for a string that is passed
- // in and return it.
- tDictEntry<T> * FindEntry(const cString & name) {
- const int bin = HashString(name);
- if (cell_array[bin] == NULL) return NULL;
-
- // Set the list iterator to the first entry of this bin.
- list_it.Set(cell_array[bin]);
-
- // Loop through all entries in this bin to see if any are a perfect match.
- while (list_it.Get() != NULL && list_it.Get()->id == bin) {
- if (list_it.Get()->name == name) return list_it.Get();
- list_it.Next();
- }
-
- // No matches found.
- return NULL;
- }
-private:
- // disabled copy constructor.
- tDictionary(const tDictionary &);
-public:
- tDictionary(int in_hash_size=DICTIONARY_HASH_DEFAULT)
- : dict_size(0)
- , hash_size(in_hash_size)
- , cell_array(in_hash_size)
- , list_it(entry_list)
- {
- cell_array.SetAll(NULL);
- }
-
- ~tDictionary() {
- while (entry_list.GetSize()) delete entry_list.Pop();
- }
-
-
- bool OK() {
- std::cout << "DICT_SIZE = " << dict_size << std::endl;
- std::cout << "HASH_SIZE = " << hash_size << std::endl;
- int count = 0;
- std::cout << "LIST ELEMENTS:" << std::endl;
- list_it.Reset();
- while (list_it.Next() != NULL) {
- tDictEntry<T> * cur_entry = list_it.Get();
- std::cout << " " << count << " : "
- << cur_entry->id << " "
- << cur_entry->name << " "
- << cur_entry->data << " "
- << std::endl;
- }
- std::cout << std::endl;
- std::cout << "ARRAY CELLS: "
- << cell_array.GetSize()
- << std::endl;
- for (int i = 0; i < hash_size; i++) {
- tListNode< tDictEntry<T> > * cur_list_node = cell_array[i];
- if (cur_list_node == NULL) {
- std::cout << " NULL" << std::endl;
- } else {
- std::cout << " " << cur_list_node->data->id
- << " " << cur_list_node->data->name
- << std::endl;
- }
- }
-
- return true;
- }
-
- int GetSize() { return dict_size; }
-
- // This function is used to add a new entry...
- void Add(const cString & name, T data) {
- // Build the new entry...
- tDictEntry<T> * new_entry = new tDictEntry<T>;
- new_entry->name = name;
- new_entry->data = data;
- const int bin = HashString(name);
- new_entry->id = bin;
-
-
- // Determine where this new entry should go; either at the end of
- // the list (if there are no others in the bin) or following another
- // entry in the bin.
- if (cell_array[bin] == NULL) { list_it.Reset(); } // Reset to list start
- else { list_it.Set(cell_array[bin]); } // Else find insert point
-
- entry_list.Insert(list_it, new_entry); // Place new entry in the list
- list_it.Prev(); // Back up to new entry
- cell_array[bin] = list_it.GetPos(); // Record position
-
- // Update our entry count...
- dict_size++;
- }
-
-
- // This function will change the value of an entry that exists, or add it
- // if it doesn't exist.
- void SetValue(const cString & name, T data) {
- tDictEntry<T> * cur_entry = FindEntry(name);
- if (cur_entry == NULL) {
- Add(name, data);
- return;
- }
- cur_entry->data = data;
- }
-
-
- bool HasEntry(const cString & name) {
- return FindEntry(name) != NULL;
- }
-
- bool Find(const cString & name, T & out_data) {
- tDictEntry<T> * found_entry = FindEntry(name);
- if (found_entry != NULL) {
- out_data = found_entry->data;
- return true;
- }
- return false;
- }
-
- T Remove(const cString & name) {
- // Determine the bin that we are going to be using.
- const int bin = HashString(name);
-
- T out_data;
- assert(cell_array[bin] != NULL);
- list_it.Set(cell_array[bin]);
-
- // If we are deleting the first entry in this bin we must clean up...
- if (list_it.Get()->name == name) {
- out_data = list_it.Get()->data;
- delete list_it.Remove();
- list_it.Next();
- dict_size--;
- // See if the next entry is still part of this cell.
- if (list_it.AtRoot() == false && list_it.Get()->id == bin) {
- cell_array[bin] = list_it.GetPos();
- } else {
- cell_array[bin] = NULL;
- }
- }
-
- // If it was not the first entry in this cell, keep looking!
- else {
- while (list_it.Next() != NULL && list_it.Get()->id == bin) {
- if (list_it.Get()->name == name) {
- out_data = list_it.Get()->data;
- delete list_it.Remove();
- dict_size--;
- break;
- }
- }
- }
-
- return out_data;
- }
-
- cString NearMatch(const cString name) {
- cString best_match("");
- int best_dist = name.GetSize();
- list_it.Reset();
- while (list_it.Next() != NULL) {
- int dist = cStringUtil::EditDistance(name, list_it.Get()->name);
- if (dist < best_dist) {
- best_dist = dist;
- best_match = list_it.Get()->name;
- }
- }
- return best_match;
- }
-
- void SetHash(int _hash) {
- // Create the new table...
- hash_size = _hash;
- cell_array.ResizeClear(hash_size);
- cell_array.SetAll(NULL);
-
- // Backup all of the entries in the list and re-insert them one-by-one.
- tList< tDictEntry<T> > backup_list;
- backup_list.Transfer(entry_list);
-
- while (backup_list.GetSize() > 0) {
- tDictEntry<T> * cur_entry = backup_list.Pop();
-
- // determine the new bin for this entry.
- int bin = HashString(cur_entry->name);
- cur_entry->id = bin;
-
- if (cell_array[bin] == NULL) { list_it.Reset(); } // Reset to list start
- else { list_it.Set(cell_array[bin]); } // Else find insert point
-
- entry_list.Insert(list_it, cur_entry); // Place new entry in the list
- list_it.Prev(); // Back up to new entry
- cell_array[bin] = list_it.GetPos(); // Record position
- }
- }
-
- // The following method allows the user to convert the dictionary contents
- // into lists. Empty lists show be passed in as arguments and the method
- // will fill in their contents.
- void AsLists(tList<cString> & name_list, tList<T> & value_list) {
- // Setup the lists to fill in.
- assert(name_list.GetSize() == 0);
- assert(value_list.GetSize() == 0);
- tListIterator<cString> name_it(name_list);
- tListIterator<T> value_it(value_list);
-
- // Loop through the current entries and included them into the output
- // list one at a time.
- list_it.Reset();
- while (list_it.Next() != NULL) {
- // Grab the info about the current entry.
- cString & cur_name = list_it.Get()->name;
- T & cur_value = list_it.Get()->data;
-
- // Find the position to place this in the lists.
- name_it.Reset();
- value_it.Reset();
- value_it.Next();
- while (name_it.Next() != NULL && cur_name > *(name_it.Get())) {
- value_it.Next();
- }
- name_list.Insert(name_it, &cur_name);
- value_list.Insert(value_it, &cur_value);
- }
- }
-};
-
-#endif
Copied: trunk/source/tools/tHashTable.h (from rev 338, trunk/source/tools/tHashTable.hh)
===================================================================
--- trunk/source/tools/tHashTable.hh 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/tools/tHashTable.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -0,0 +1,335 @@
+//////////////////////////////////////////////////////////////////////////////
+// Copyright (C) 1993 - 2005 California Institute of Technology //
+// //
+// Read the COPYING and README files, or contact 'avida at alife.org', //
+// before continuing. SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE. //
+//////////////////////////////////////////////////////////////////////////////
+
+/*
+ * This template is used to look up objects of the desired type by an integer
+ * hash ID. It is implemented through use of a linked list that contains all
+ * of the individual entries stored in the table (in an arbitrary order).
+ * The hash table points to the first entry in the list that fits in its
+ * cell. If there are no entries that fit in the cell, the table contains a
+ * NULL pointer at that location.
+ *
+ * The inputs are HASH_TYPE and DATA_TYPE
+ *
+ * INTERFACE:
+ * tHashTable(int in_hash_size=DICTIONARY_HASH_DEFAULT) // Constructor
+ * ~tHashTable() // Destructor
+ * int GetSize() // Get num entries
+ * void Add(const HASH_TYPE & key, DATA_TYPE data) // Add new entry
+ * void SetValue(const HASH_TYPE & key, DATA_TYPE data) // Add/modify entry
+ * bool HasEntry(const HASH_TYPE & key) // Test if key exists
+ * bool Find(const HASH_TYPE & key, T & out_data) // Find entry for key
+ * T Remove(const HASH_TYPE & key) // Remove entry
+ * void SetTableSize(int _hash) // Change hash table size
+ *
+ *
+ * IMPLEMENTATION NOTES:
+ *
+ * On INSERT: If a cell already has at least one entry in it, the new entry
+ * gets inserted into the linked list before the existing entry. If the cell
+ * is currently empty, the new entry gets placed at the end of the linked
+ * list. In either case, the cell is updated to point at the new entry.
+ *
+ * On DELETE: Start looking at the position in the list where the cell is
+ * pointing and continue until the entry-to-be-deleted is found. If the
+ * entry to be deleted is the one being pointed at, be sure to update the
+ * cell.
+ *
+ * On LOOKUP: If the cell has a NULL pointer, lookup fails. Otherwise search
+ * through list until either correct entry is found (lookup succeeds) or else
+ * the lookup finds an entry not in the current cell (lookup fails).
+ */
+
+#ifndef THASH_TABLE_HH
+#define THASH_TABLE_HH
+
+#ifndef STRING_HH
+#include "cString.h"
+#endif
+#ifndef STRING_UTIL_HH
+#include "cStringUtil.h"
+#endif
+#ifndef TARRAY_HH
+#include "tArray.h"
+#endif
+#ifndef TLIST_HH
+#include "tList.h"
+#endif
+
+#define HASH_TABLE_SIZE_DEFAULT 23
+#define HASH_TABLE_SIZE_MEDIUM 331
+#define HASH_TABLE_SIZE_LARGE 2311
+
+template <class DATA_TYPE> class tList; // access
+template <class DATA_TYPE> class tListIterator; // aggregate
+
+template <class HASH_TYPE, class DATA_TYPE> class tHashTable {
+
+ // We create a structure with full information about each entry stored in
+ // this dictionary.
+ template <class E_HASH_TYPE, class E_DATA_TYPE> struct tHashEntry {
+ E_HASH_TYPE key;
+ int id;
+ E_DATA_TYPE data;
+ };
+
+private:
+ int entry_count; // How many entries are we storing?
+ int table_size; // What size hash table are we using?
+
+ // Create a linked list of all hash entries in the table, as well as a
+ // companion array with pointers into the list that will give the start of
+ // each hash entry.
+ tList< tHashEntry<HASH_TYPE, DATA_TYPE> > entry_list;
+ tArray< tListNode< tHashEntry<HASH_TYPE, DATA_TYPE> > * > cell_array;
+
+ // Create an iterator for entry_list
+ tListIterator< tHashEntry<HASH_TYPE, DATA_TYPE> > list_it;
+
+ // Create a set of HashKey methods for each of the basic data types that
+ // we allow:
+
+ // HASH_TYPE = int
+ // Simply mod the into by the size of the hash table and hope for the best
+ int HashKey(const int & key) const {
+ return key % table_size;
+ }
+
+ // HASH_TYPE = cString
+ // We hash a string simply by adding up the individual character values in
+ // that string and modding by the hash size. For most applications this
+ // will work fine (and reasonably fast!) but some patterns will cause all
+ // strings to go into the same cell. For example, "ABC"=="CBA"=="BBB".
+ int HashKey(const cString & key) const {
+ unsigned int out_hash = 0;
+ for (int i = 0; i < key.GetSize(); i++)
+ out_hash += (unsigned int) key[i];
+ return out_hash % table_size;
+ }
+
+ // Function to find the appropriate tHashEntry for a key that is passed
+ // in and return it.
+ tHashEntry<HASH_TYPE, DATA_TYPE> * FindEntry(const HASH_TYPE & key) {
+ const int bin = HashKey(key);
+ if (cell_array[bin] == NULL) return NULL;
+
+ // Set the list iterator to the first entry of this bin.
+ list_it.Set(cell_array[bin]);
+
+ // Loop through all entries in this bin to see if any are a perfect match.
+ while (list_it.Get() != NULL && list_it.Get()->id == bin) {
+ if (list_it.Get()->key == key) return list_it.Get();
+ list_it.Next();
+ }
+
+ // No matches found.
+ return NULL;
+ }
+private:
+ // disabled copy constructor.
+ tHashTable(const tHashTable &);
+public:
+ tHashTable(int in_table_size=HASH_TABLE_SIZE_DEFAULT)
+ : entry_count(0)
+ , table_size(in_table_size)
+ , cell_array(in_table_size)
+ , list_it(entry_list)
+ {
+ cell_array.SetAll(NULL);
+ }
+
+ ~tHashTable() {
+ while (entry_list.GetSize()) delete entry_list.Pop();
+ }
+
+ void ClearAll() {
+ list_it.Reset();
+ while (list_it.Next() != NULL) {
+ delete list_it.Remove();
+ }
+ entry_count = 0;
+ cell_array.SetAll(NULL);
+ }
+
+
+ bool OK() {
+ std::cout << "ENTRY_COUNT = " << entry_count << std::endl;
+ std::cout << "TABLE_SIZE = " << table_size << std::endl;
+ int count = 0;
+ std::cout << "LIST ELEMENTS:" << std::endl;
+ list_it.Reset();
+ while (list_it.Next() != NULL) {
+ tHashEntry<HASH_TYPE, DATA_TYPE> * cur_entry = list_it.Get();
+ std::cout << " " << count << " : "
+ << cur_entry->id << " "
+ << cur_entry->key << " "
+ << cur_entry->data << " "
+ << std::endl;
+ }
+ std::cout << std::endl;
+ std::cout << "ARRAY CELLS: "
+ << cell_array.GetSize()
+ << std::endl;
+ for (int i = 0; i < table_size; i++) {
+ tListNode< tHashEntry<HASH_TYPE, DATA_TYPE> > * cur_list_node = cell_array[i];
+ if (cur_list_node == NULL) {
+ std::cout << " NULL" << std::endl;
+ } else {
+ std::cout << " " << cur_list_node->data->id << " " << cur_list_node->data->key << std::endl;
+ }
+ }
+
+ return true;
+ }
+
+ int GetSize() { return entry_count; }
+
+ // This function is used to add a new entry...
+ void Add(const HASH_TYPE & key, DATA_TYPE data) {
+ // Build the new entry...
+ tHashEntry<HASH_TYPE, DATA_TYPE> * new_entry = new tHashEntry<HASH_TYPE, DATA_TYPE>;
+ new_entry->key = key;
+ new_entry->data = data;
+ const int bin = HashKey(key);
+ new_entry->id = bin;
+
+
+ // Determine where this new entry should go; either at the end of
+ // the list (if there are no others in the bin) or following another
+ // entry in the bin.
+ if (cell_array[bin] == NULL) { list_it.Reset(); } // Reset to list start
+ else { list_it.Set(cell_array[bin]); } // Else find insert point
+
+ entry_list.Insert(list_it, new_entry); // Place new entry in the list
+ list_it.Prev(); // Back up to new entry
+ cell_array[bin] = list_it.GetPos(); // Record position
+
+ // Update our entry count...
+ entry_count++;
+ }
+
+
+ // This function will change the value of an entry that exists, or add it
+ // if it doesn't exist.
+ void SetValue(const HASH_TYPE & key, DATA_TYPE data) {
+ tHashEntry<HASH_TYPE, DATA_TYPE> * cur_entry = FindEntry(key);
+ if (cur_entry == NULL) {
+ Add(key, data);
+ return;
+ }
+ cur_entry->data = data;
+ }
+
+
+ bool HasEntry(const HASH_TYPE & key) {
+ return FindEntry(key) != NULL;
+ }
+
+ bool Find(const HASH_TYPE & key, DATA_TYPE & out_data) {
+ tHashEntry<HASH_TYPE, DATA_TYPE> * found_entry = FindEntry(key);
+ if (found_entry != NULL) {
+ out_data = found_entry->data;
+ return true;
+ }
+ return false;
+ }
+
+ DATA_TYPE Remove(const HASH_TYPE & key) {
+ // Determine the bin that we are going to be using.
+ const int bin = HashKey(key);
+
+ DATA_TYPE out_data;
+ assert(cell_array[bin] != NULL);
+ list_it.Set(cell_array[bin]);
+
+ // If we are deleting the first entry in this bin we must clean up...
+ if (list_it.Get()->key == key) {
+ out_data = list_it.Get()->data;
+ delete list_it.Remove();
+ list_it.Next();
+ entry_count--;
+ // See if the next entry is still part of this cell.
+ if (list_it.AtRoot() == false && list_it.Get()->id == bin) {
+ cell_array[bin] = list_it.GetPos();
+ } else {
+ cell_array[bin] = NULL;
+ }
+ }
+
+ // If it was not the first entry in this cell, keep looking!
+ else {
+ while (list_it.Next() != NULL && list_it.Get()->id == bin) {
+ if (list_it.Get()->key == key) {
+ out_data = list_it.Get()->data;
+ delete list_it.Remove();
+ entry_count--;
+ break;
+ }
+ }
+ }
+
+ return out_data;
+ }
+
+ void SetTableSize(int _hash) {
+ // Create the new table...
+ table_size = _hash;
+ cell_array.ResizeClear(table_size);
+ cell_array.SetAll(NULL);
+
+ // Backup all of the entries in the list and re-insert them one-by-one.
+ tList< tHashEntry<HASH_TYPE, DATA_TYPE> > backup_list;
+ backup_list.Transfer(entry_list);
+
+ while (backup_list.GetSize() > 0) {
+ tHashEntry<HASH_TYPE, DATA_TYPE> * cur_entry = backup_list.Pop();
+
+ // determine the new bin for this entry.
+ int bin = HashKey(cur_entry->key);
+ cur_entry->id = bin;
+
+ if (cell_array[bin] == NULL) { list_it.Reset(); } // Reset to list start
+ else { list_it.Set(cell_array[bin]); } // Else find insert point
+
+ entry_list.Insert(list_it, cur_entry); // Place new entry in the list
+ list_it.Prev(); // Back up to new entry
+ cell_array[bin] = list_it.GetPos(); // Record position
+ }
+ }
+
+ // The following method allows the user to convert the dictionary contents
+ // into lists. Empty lists show be passed in as arguments and the method
+ // will fill in their contents.
+ void AsLists(tList<HASH_TYPE> & key_list, tList<DATA_TYPE> & value_list) {
+ // Setup the lists to fill in.
+ assert(key_list.GetSize() == 0);
+ assert(value_list.GetSize() == 0);
+ tListIterator<HASH_TYPE> key_it(key_list);
+ tListIterator<DATA_TYPE> value_it(value_list);
+
+ // Loop through the current entries and included them into the output
+ // list one at a time.
+ list_it.Reset();
+ while (list_it.Next() != NULL) {
+ // Grab the info about the current entry.
+ HASH_TYPE & cur_key = list_it.Get()->key;
+ DATA_TYPE & cur_value = list_it.Get()->data;
+
+ // Find the position to place this in the lists.
+ key_it.Reset();
+ value_it.Reset();
+ value_it.Next();
+ while (key_it.Next() != NULL && cur_key > *(key_it.Get())) {
+ value_it.Next();
+ }
+ key_list.Insert(key_it, &cur_key);
+ value_list.Insert(value_it, &cur_value);
+ }
+ }
+};
+
+#endif
Deleted: trunk/source/tools/tHashTable.hh
===================================================================
--- trunk/source/tools/tHashTable.hh 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/tools/tHashTable.hh 2005-10-10 23:44:52 UTC (rev 339)
@@ -1,335 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// Copyright (C) 1993 - 2005 California Institute of Technology //
-// //
-// Read the COPYING and README files, or contact 'avida at alife.org', //
-// before continuing. SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE. //
-//////////////////////////////////////////////////////////////////////////////
-
-/*
- * This template is used to look up objects of the desired type by an integer
- * hash ID. It is implemented through use of a linked list that contains all
- * of the individual entries stored in the table (in an arbitrary order).
- * The hash table points to the first entry in the list that fits in its
- * cell. If there are no entries that fit in the cell, the table contains a
- * NULL pointer at that location.
- *
- * The inputs are HASH_TYPE and DATA_TYPE
- *
- * INTERFACE:
- * tHashTable(int in_hash_size=DICTIONARY_HASH_DEFAULT) // Constructor
- * ~tHashTable() // Destructor
- * int GetSize() // Get num entries
- * void Add(const HASH_TYPE & key, DATA_TYPE data) // Add new entry
- * void SetValue(const HASH_TYPE & key, DATA_TYPE data) // Add/modify entry
- * bool HasEntry(const HASH_TYPE & key) // Test if key exists
- * bool Find(const HASH_TYPE & key, T & out_data) // Find entry for key
- * T Remove(const HASH_TYPE & key) // Remove entry
- * void SetTableSize(int _hash) // Change hash table size
- *
- *
- * IMPLEMENTATION NOTES:
- *
- * On INSERT: If a cell already has at least one entry in it, the new entry
- * gets inserted into the linked list before the existing entry. If the cell
- * is currently empty, the new entry gets placed at the end of the linked
- * list. In either case, the cell is updated to point at the new entry.
- *
- * On DELETE: Start looking at the position in the list where the cell is
- * pointing and continue until the entry-to-be-deleted is found. If the
- * entry to be deleted is the one being pointed at, be sure to update the
- * cell.
- *
- * On LOOKUP: If the cell has a NULL pointer, lookup fails. Otherwise search
- * through list until either correct entry is found (lookup succeeds) or else
- * the lookup finds an entry not in the current cell (lookup fails).
- */
-
-#ifndef THASH_TABLE_HH
-#define THASH_TABLE_HH
-
-#ifndef STRING_HH
-#include "cString.h"
-#endif
-#ifndef STRING_UTIL_HH
-#include "cStringUtil.h"
-#endif
-#ifndef TARRAY_HH
-#include "tArray.hh"
-#endif
-#ifndef TLIST_HH
-#include "tList.hh"
-#endif
-
-#define HASH_TABLE_SIZE_DEFAULT 23
-#define HASH_TABLE_SIZE_MEDIUM 331
-#define HASH_TABLE_SIZE_LARGE 2311
-
-template <class DATA_TYPE> class tList; // access
-template <class DATA_TYPE> class tListIterator; // aggregate
-
-template <class HASH_TYPE, class DATA_TYPE> class tHashTable {
-
- // We create a structure with full information about each entry stored in
- // this dictionary.
- template <class E_HASH_TYPE, class E_DATA_TYPE> struct tHashEntry {
- E_HASH_TYPE key;
- int id;
- E_DATA_TYPE data;
- };
-
-private:
- int entry_count; // How many entries are we storing?
- int table_size; // What size hash table are we using?
-
- // Create a linked list of all hash entries in the table, as well as a
- // companion array with pointers into the list that will give the start of
- // each hash entry.
- tList< tHashEntry<HASH_TYPE, DATA_TYPE> > entry_list;
- tArray< tListNode< tHashEntry<HASH_TYPE, DATA_TYPE> > * > cell_array;
-
- // Create an iterator for entry_list
- tListIterator< tHashEntry<HASH_TYPE, DATA_TYPE> > list_it;
-
- // Create a set of HashKey methods for each of the basic data types that
- // we allow:
-
- // HASH_TYPE = int
- // Simply mod the into by the size of the hash table and hope for the best
- int HashKey(const int & key) const {
- return key % table_size;
- }
-
- // HASH_TYPE = cString
- // We hash a string simply by adding up the individual character values in
- // that string and modding by the hash size. For most applications this
- // will work fine (and reasonably fast!) but some patterns will cause all
- // strings to go into the same cell. For example, "ABC"=="CBA"=="BBB".
- int HashKey(const cString & key) const {
- unsigned int out_hash = 0;
- for (int i = 0; i < key.GetSize(); i++)
- out_hash += (unsigned int) key[i];
- return out_hash % table_size;
- }
-
- // Function to find the appropriate tHashEntry for a key that is passed
- // in and return it.
- tHashEntry<HASH_TYPE, DATA_TYPE> * FindEntry(const HASH_TYPE & key) {
- const int bin = HashKey(key);
- if (cell_array[bin] == NULL) return NULL;
-
- // Set the list iterator to the first entry of this bin.
- list_it.Set(cell_array[bin]);
-
- // Loop through all entries in this bin to see if any are a perfect match.
- while (list_it.Get() != NULL && list_it.Get()->id == bin) {
- if (list_it.Get()->key == key) return list_it.Get();
- list_it.Next();
- }
-
- // No matches found.
- return NULL;
- }
-private:
- // disabled copy constructor.
- tHashTable(const tHashTable &);
-public:
- tHashTable(int in_table_size=HASH_TABLE_SIZE_DEFAULT)
- : entry_count(0)
- , table_size(in_table_size)
- , cell_array(in_table_size)
- , list_it(entry_list)
- {
- cell_array.SetAll(NULL);
- }
-
- ~tHashTable() {
- while (entry_list.GetSize()) delete entry_list.Pop();
- }
-
- void ClearAll() {
- list_it.Reset();
- while (list_it.Next() != NULL) {
- delete list_it.Remove();
- }
- entry_count = 0;
- cell_array.SetAll(NULL);
- }
-
-
- bool OK() {
- std::cout << "ENTRY_COUNT = " << entry_count << std::endl;
- std::cout << "TABLE_SIZE = " << table_size << std::endl;
- int count = 0;
- std::cout << "LIST ELEMENTS:" << std::endl;
- list_it.Reset();
- while (list_it.Next() != NULL) {
- tHashEntry<HASH_TYPE, DATA_TYPE> * cur_entry = list_it.Get();
- std::cout << " " << count << " : "
- << cur_entry->id << " "
- << cur_entry->key << " "
- << cur_entry->data << " "
- << std::endl;
- }
- std::cout << std::endl;
- std::cout << "ARRAY CELLS: "
- << cell_array.GetSize()
- << std::endl;
- for (int i = 0; i < table_size; i++) {
- tListNode< tHashEntry<HASH_TYPE, DATA_TYPE> > * cur_list_node = cell_array[i];
- if (cur_list_node == NULL) {
- std::cout << " NULL" << std::endl;
- } else {
- std::cout << " " << cur_list_node->data->id << " " << cur_list_node->data->key << std::endl;
- }
- }
-
- return true;
- }
-
- int GetSize() { return entry_count; }
-
- // This function is used to add a new entry...
- void Add(const HASH_TYPE & key, DATA_TYPE data) {
- // Build the new entry...
- tHashEntry<HASH_TYPE, DATA_TYPE> * new_entry = new tHashEntry<HASH_TYPE, DATA_TYPE>;
- new_entry->key = key;
- new_entry->data = data;
- const int bin = HashKey(key);
- new_entry->id = bin;
-
-
- // Determine where this new entry should go; either at the end of
- // the list (if there are no others in the bin) or following another
- // entry in the bin.
- if (cell_array[bin] == NULL) { list_it.Reset(); } // Reset to list start
- else { list_it.Set(cell_array[bin]); } // Else find insert point
-
- entry_list.Insert(list_it, new_entry); // Place new entry in the list
- list_it.Prev(); // Back up to new entry
- cell_array[bin] = list_it.GetPos(); // Record position
-
- // Update our entry count...
- entry_count++;
- }
-
-
- // This function will change the value of an entry that exists, or add it
- // if it doesn't exist.
- void SetValue(const HASH_TYPE & key, DATA_TYPE data) {
- tHashEntry<HASH_TYPE, DATA_TYPE> * cur_entry = FindEntry(key);
- if (cur_entry == NULL) {
- Add(key, data);
- return;
- }
- cur_entry->data = data;
- }
-
-
- bool HasEntry(const HASH_TYPE & key) {
- return FindEntry(key) != NULL;
- }
-
- bool Find(const HASH_TYPE & key, DATA_TYPE & out_data) {
- tHashEntry<HASH_TYPE, DATA_TYPE> * found_entry = FindEntry(key);
- if (found_entry != NULL) {
- out_data = found_entry->data;
- return true;
- }
- return false;
- }
-
- DATA_TYPE Remove(const HASH_TYPE & key) {
- // Determine the bin that we are going to be using.
- const int bin = HashKey(key);
-
- DATA_TYPE out_data;
- assert(cell_array[bin] != NULL);
- list_it.Set(cell_array[bin]);
-
- // If we are deleting the first entry in this bin we must clean up...
- if (list_it.Get()->key == key) {
- out_data = list_it.Get()->data;
- delete list_it.Remove();
- list_it.Next();
- entry_count--;
- // See if the next entry is still part of this cell.
- if (list_it.AtRoot() == false && list_it.Get()->id == bin) {
- cell_array[bin] = list_it.GetPos();
- } else {
- cell_array[bin] = NULL;
- }
- }
-
- // If it was not the first entry in this cell, keep looking!
- else {
- while (list_it.Next() != NULL && list_it.Get()->id == bin) {
- if (list_it.Get()->key == key) {
- out_data = list_it.Get()->data;
- delete list_it.Remove();
- entry_count--;
- break;
- }
- }
- }
-
- return out_data;
- }
-
- void SetTableSize(int _hash) {
- // Create the new table...
- table_size = _hash;
- cell_array.ResizeClear(table_size);
- cell_array.SetAll(NULL);
-
- // Backup all of the entries in the list and re-insert them one-by-one.
- tList< tHashEntry<HASH_TYPE, DATA_TYPE> > backup_list;
- backup_list.Transfer(entry_list);
-
- while (backup_list.GetSize() > 0) {
- tHashEntry<HASH_TYPE, DATA_TYPE> * cur_entry = backup_list.Pop();
-
- // determine the new bin for this entry.
- int bin = HashKey(cur_entry->key);
- cur_entry->id = bin;
-
- if (cell_array[bin] == NULL) { list_it.Reset(); } // Reset to list start
- else { list_it.Set(cell_array[bin]); } // Else find insert point
-
- entry_list.Insert(list_it, cur_entry); // Place new entry in the list
- list_it.Prev(); // Back up to new entry
- cell_array[bin] = list_it.GetPos(); // Record position
- }
- }
-
- // The following method allows the user to convert the dictionary contents
- // into lists. Empty lists show be passed in as arguments and the method
- // will fill in their contents.
- void AsLists(tList<HASH_TYPE> & key_list, tList<DATA_TYPE> & value_list) {
- // Setup the lists to fill in.
- assert(key_list.GetSize() == 0);
- assert(value_list.GetSize() == 0);
- tListIterator<HASH_TYPE> key_it(key_list);
- tListIterator<DATA_TYPE> value_it(value_list);
-
- // Loop through the current entries and included them into the output
- // list one at a time.
- list_it.Reset();
- while (list_it.Next() != NULL) {
- // Grab the info about the current entry.
- HASH_TYPE & cur_key = list_it.Get()->key;
- DATA_TYPE & cur_value = list_it.Get()->data;
-
- // Find the position to place this in the lists.
- key_it.Reset();
- value_it.Reset();
- value_it.Next();
- while (key_it.Next() != NULL && cur_key > *(key_it.Get())) {
- value_it.Next();
- }
- key_list.Insert(key_it, &cur_key);
- value_list.Insert(value_it, &cur_value);
- }
- }
-};
-
-#endif
Copied: trunk/source/tools/tList.h (from rev 338, trunk/source/tools/tList.hh)
Deleted: trunk/source/tools/tList.hh
===================================================================
--- trunk/source/tools/tList.hh 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/tools/tList.hh 2005-10-10 23:44:52 UTC (rev 339)
@@ -1,550 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// Copyright (C) 1993 - 2003 California Institute of Technology //
-// //
-// Read the COPYING and README files, or contact 'avida at alife.org', //
-// before continuing. SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE. //
-//////////////////////////////////////////////////////////////////////////////
-
-#ifndef TLIST_HH
-#define TLIST_HH
-
-#ifndef NULL
-#define NULL 0
-#endif
-
-template <class T> class tListNode {
-public:
- T * data;
- tListNode<T> * next;
- tListNode<T> * prev;
-
- tListNode() : data(NULL), next(this), prev(this) { ; }
-};
-
-template <class T> class tList;
-
-template <class T> class tBaseIterator {
- friend class tList<T>;
-protected:
- virtual const tList<T> & GetConstList() = 0;
- virtual const tListNode<T> * GetConstNode() = 0;
-public:
- tBaseIterator() { ; }
- virtual ~tBaseIterator() { ; }
-
- virtual void Set(tListNode<T> * in_node) = 0;
- virtual void Reset() = 0;
-
- virtual const T * GetConst() = 0;
- virtual const T * NextConst() = 0;
- virtual const T * PrevConst() = 0;
-
- virtual bool AtRoot() const = 0;
- virtual bool AtEnd() const = 0;
-};
-
-template <class T> class tListIterator : public tBaseIterator<T> {
- friend class tList<T>;
-private:
- tList<T> & list;
- tListNode<T> * node;
-
- const tList<T> & GetConstList() { return list; }
- const tListNode<T> * GetConstNode() { return node; }
-public:
- explicit tListIterator(tList<T> & _list);
- explicit tListIterator(tList<T> & _list, tListNode<T> * start_node);
- ~tListIterator();
-
- void Set(tListNode<T> * in_node) { node = in_node; }
- void Reset();
- tListNode<T> * GetPos() { return node; }
-
- T * Get();
- T * Next();
- T * Prev();
- const T * GetConst() { return Get(); }
- const T * NextConst() { return Next(); }
- const T * PrevConst() { return Prev(); }
-
- bool Find(T * test_data);
-
- bool AtRoot() const;
- bool AtEnd() const;
-
- // Unique methods...
- T * Remove();
-};
-
-template <class T> class tConstListIterator : public tBaseIterator<T> {
- friend class tList<T>;
-private:
- const tList<T> & list;
- const tListNode<T> * node;
-
- const tList<T> & GetConstList() { return list; }
- const tListNode<T> * GetConstNode() { return node; }
-public:
- explicit tConstListIterator(const tList<T> & _list);
- explicit tConstListIterator(const tList<T> & _list,
- const tListNode<T> * start_node);
- ~tConstListIterator();
-
- void Set(tListNode<T> * in_node) { node = in_node; }
- void Reset();
-
- const T * Get();
- const T * Next();
- const T * Prev();
- const T * GetConst() { return Get(); }
- const T * NextConst() { return Next(); }
- const T * PrevConst() { return Prev(); }
- bool Find(const T * test_data);
-
- bool AtRoot() const;
- bool AtEnd() const;
-};
-
-template <class T> class tList {
- friend class tBaseIterator<T>;
- friend class tListIterator<T>;
- friend class tConstListIterator<T>;
-protected:
- tListNode<T> root; // Data root
- int size;
- mutable tListNode< tBaseIterator<T> > it_root; // Iterator root
- mutable int it_count;
-
- T * RemoveNode(tListNode<T> * out_node) {
- // Make sure we're not trying to delete the root node!
- if (out_node == &root) return NULL;
-
- // Adjust any iterators on the deleted node.
- tListNode< tBaseIterator<T> > * test_it = it_root.next;
- while (test_it != &it_root) {
- // If this iterator is on this node, move it back one.
- if (test_it->data->GetConstNode() == out_node) {
- test_it->data->PrevConst();
- }
- test_it = test_it->next;
- }
-
- // Save the data and patch up the linked list.
- T * out_data = out_node->data;
- out_node->prev->next = out_node->next;
- out_node->next->prev = out_node->prev;
-
- // Cleanup and return
- size--;
- delete out_node;
- return out_data;
- }
-
- // To be called from iterator constructor only!
- void AddIterator(tBaseIterator<T> * new_it) const {
- tListNode< tBaseIterator<T> > * new_node =
- new tListNode< tBaseIterator<T> >;
- new_node->data = new_it;
- new_node->next = it_root.next;
- new_node->prev = &it_root;
- it_root.next->prev = new_node;
- it_root.next = new_node;
- it_count++;
- }
-
- // To be called from iterator destructor only!
- void RemoveIterator(tBaseIterator<T> * old_it) const {
- tListNode< tBaseIterator<T> > * test_it = it_root.next;
- while (test_it->data != old_it) test_it = test_it->next;
- test_it->prev->next = test_it->next;
- test_it->next->prev = test_it->prev;
- delete test_it;
- it_count--;
- }
-
-public:
- T * Pop() { return RemoveNode(root.next); }
- T * PopRear() { return RemoveNode(root.prev); }
-
- void Clear() { while (size > 0) Pop(); }
-
- void Append(const tList<T> & in_list) {
- tListNode<T> * cur_node = in_list.root.next;
- while (cur_node != &(in_list.root)) {
- PushRear(cur_node->data);
- cur_node = cur_node->next;
- }
- }
-
- void Copy(const tList<T> & in_list) {
- Clear();
- Append(in_list);
- }
-
- void Push(T * _in) {
- tListNode<T> * new_node = new tListNode<T>;
- new_node->data = _in;
- new_node->next = root.next;
- new_node->prev = &root;
- root.next->prev = new_node;
- root.next = new_node;
- size++;
- }
-
- void PushRear(T * _in) {
- tListNode<T> * new_node = new tListNode<T>;
- new_node->data = _in;
- new_node->next = &root;
- new_node->prev = root.prev;
- root.prev->next = new_node;
- root.prev = new_node;
- size++;
- }
-
- const T * GetFirst() const { return root.next->data; }
- const T * GetLast() const { return root.prev->data; }
- T * GetFirst() { return root.next->data; }
- T * GetLast() { return root.prev->data; }
-
- T * GetPos(int pos) {
- if (pos >= GetSize()) return NULL;
- tListNode<T> * test_node = root.next;
- for (int i = 0; i < pos; i++) test_node = test_node->next;
- return test_node->data;
- }
-
- const T * GetPos(int pos) const {
- if (pos >= GetSize()) return NULL;
- tListNode<T> * test_node = root.next;
- for (int i = 0; i < pos; i++) test_node = test_node->next;
- return test_node->data;
- }
-
- void CircNext() { if (size > 0) PushRear(Pop()); }
- void CircPrev() { if (size > 0) Push(PopRear()); }
-
- T * Remove(tListIterator<T> & other) {
- if (&(other.list) != this) return NULL; // @CAO make this an assert?
- return RemoveNode(other.node);
- }
-
- T * Insert(tListIterator<T> & list_it, T * in_data) {
- tListNode<T> * cur_node = list_it.node;
-
- // Build the new node for the list...
- tListNode<T> * new_node = new tListNode<T>;
- new_node->data = in_data;
-
- // Insert the new node before the iterator...
- new_node->next = cur_node;
- new_node->prev = cur_node->prev;
- cur_node->prev->next = new_node;
- cur_node->prev = new_node;
- size++;
-
- return in_data;
- }
-
-
- //bool Remove(T * other) {
- T * Remove(T * other) {
- tListNode<T> * test = root.next;
- while (test != &root) {
- if (test->data == other) {
- RemoveNode(test);
- //return true;
- return other;
- }
- test = test->next;
- }
- //return false;
- return NULL;
- }
-
- int GetSize() const { return size; }
-
- // Copy another list onto the end of this one.
- void Append(tList<T> & other_list) {
- tListIterator<T> other_it(other_list);
- while (other_it.Next() != NULL) PushRear(other_it.Get());
- }
-
- // Empty out another list, transferring its contents to the end of this one.
- void Transfer(tList<T> & other_list) {
- // If the other list is empty, stop here.
- if (other_list.GetSize() == 0) return;
-
- // Hook this list into the other one.
- other_list.root.next->prev = root.prev;
- other_list.root.prev->next = &root;
- root.prev->next = other_list.root.next;
- root.prev = other_list.root.prev;
-
- // Clean up the other list so it has no entries.
- other_list.root.next = &(other_list.root);
- other_list.root.prev = &(other_list.root);
-
- // Update the size
- size += other_list.size;
- other_list.size = 0;
-
- // Update all iterators in the other list to point at the root.
- tListNode< tBaseIterator<T> > * test_it = other_list.it_root.next;
- while (test_it != &other_list.it_root) {
- test_it->data->Reset();
- test_it = test_it->next;
- }
- }
-
- // Find by value
- T * Find(T * _in) const {
- tListNode<T> * test = root.next;
- while (test != &root) {
- if ( *(test->data) == *(_in) ) return test->data;
- test = test->next;
- }
- return NULL;
- }
-
- // Find by Pointer
- T * FindPtr(T * _in) const {
- tListNode<T> * test = root.next;
- while (test != &root) {
- if ( test->data == _in ) return test->data;
- test = test->next;
- }
- return NULL;
- }
-
- // Find the position of the node by its pointer
- int FindPosPtr(T * _in) const {
- tListNode<T> * test = root.next;
- int pos = 0;
- while (test != &root) {
- if ( test->data == _in ) return pos;
- test = test->next;
- pos++;
- }
- return 0;
- }
-
-
- // Remove by position
- T * PopPos(int pos) {
- if (pos >= GetSize()) return NULL;
- tListNode<T> * test_node = root.next;
- for (int i = 0; i < pos; i++) test_node = test_node->next;
- return RemoveNode(test_node);
- }
-
-
-public:
- tList() : size(0), it_count(0) { }
- ~tList() { Clear(); }
-private:
- tList(tList & _list) { ; } // Never should be used...
- };
-
-
-// This is an extended version of tList that contains extra functions to
-// allow method pointer associated with the object type being listed.
-template <class T> class tListPlus : public tList<T> {
-private:
-public:
-
- // Find by summing values until a specified total is reached.
- T * FindSummedValue(int sum, int (T::*fun)() const) {
- int total = 0;
- tListNode<T> * test = this->root.next;
- while (test != &(this->root) && total < sum) {
- total += (test->data->*fun)();
- test = test->next;
- }
- return test->data;
- }
-
- T * PopIntValue(int (T::*fun)() const, int value) {
- tListNode<T> * test = this->root.next;
- while (test != &(this->root)) {
- if ( (test->data->*fun)() == value) return RemoveNode(test);
- test = test->next;
- }
- return NULL;
- }
-
- T * PopIntMax(int (T::*fun)() const) {
- if (this->size == 0) return NULL;
- tListNode<T> * test = this->root.next;
- tListNode<T> * best = test;
- int max_val = (test->data->*fun)();
- while (test != &(this->root)) {
- const int cur_val = (test->data->*fun)();
- if ( cur_val > max_val ) {
- max_val = cur_val;
- best = test;
- }
- test = test->next;
- }
- return RemoveNode(best);
- }
-
- T * PopDoubleMax(double (T::*fun)() const) {
- if (this->size == 0) return NULL;
- tListNode<T> * test = this->root.next;
- tListNode<T> * best = test;
- double max_val = (test->data->*fun)();
- while (test != &(this->root)) {
- const double cur_val = (test->data->*fun)();
- if ( cur_val > max_val ) {
- max_val = cur_val;
- best = test;
- }
- test = test->next;
- }
- return RemoveNode(best);
- }
-
- int Count(int (T::*fun)() const) {
- int total = 0;
- tListNode<T> * test = this->root.next;
- while (test != &(this->root)) {
- total += (test->data->*fun)();
- test = test->next;
- }
- return total;
- }
-
-};
-
-
-////////////////////
-// tListIterator
-
-template <class T> tListIterator<T>::tListIterator(tList<T> & _list)
-: list(_list), node(&(_list.root))
-{
- list.AddIterator(this);
-}
-
-template <class T> tListIterator<T>::tListIterator(tList<T> & _list,
- tListNode<T> * start_node)
-: list(_list), node(start_node)
-{
- list.AddIterator(this);
-}
-
-template <class T> tListIterator<T>::~tListIterator()
-{
- list.RemoveIterator(this);
-}
-
-template <class T> void tListIterator<T>::Reset()
-{
- node = &(list.root);
-}
-
-template <class T> T * tListIterator<T>::Get()
-{
- return node->data;
-}
-
-template <class T> T * tListIterator<T>::Next()
-{
- node = node->next;
- return node->data;
-}
-
-template <class T> T * tListIterator<T>::Prev()
-{
- node = node->prev;
- return node->data;
-}
-
-template <class T> bool tListIterator<T>::Find(T * test_data)
-{
- for (node = list.root.next;
- node != &(list.root);
- node = node->next) {
- if (node->data == test_data) return true;
- }
- return false;
-}
-
-template <class T> bool tListIterator<T>::AtRoot() const
-{
- return (node == &(list.root));
-}
-
-template <class T> bool tListIterator<T>::AtEnd() const
-{
- return (node->next == &(list.root));
-}
-
-template <class T> T* tListIterator<T>::Remove()
-{
- return list.RemoveNode(node);
-}
-
-/////////////////////////
-// tConstListIterator
-
-template <class T> tConstListIterator<T>::tConstListIterator(const tList<T> & _list)
-: list(_list), node(&(_list.root))
-{
- list.AddIterator(this);
-}
-
-template <class T> tConstListIterator<T>::tConstListIterator(const tList<T> & _list, const tListNode<T> * start_node)
-: list(_list), node(start_node)
-{
- list.AddIterator(this);
-}
-
-template <class T> tConstListIterator<T>::~tConstListIterator()
-{
- list.RemoveIterator(this);
-}
-
-template <class T> void tConstListIterator<T>::Reset()
-{
- node = &(list.root);
-}
-
-template <class T> const T * tConstListIterator<T>::Get()
-{
- return node->data;
-}
-
-template <class T> const T * tConstListIterator<T>::Next()
-{
- node = node->next;
- return node->data;
-}
-
-template <class T> const T * tConstListIterator<T>::Prev()
-{
- node = node->prev;
- return node->data;
-}
-
-template <class T> bool tConstListIterator<T>::Find(const T * test_data)
-{
- for (node = list.root.next;
- node != &(list.root);
- node = node->next) {
- if (node->data == test_data) return true;
- }
- return false;
-}
-
-template <class T> bool tConstListIterator<T>::AtRoot() const
-{
- return (node == &(list.root));
-}
-
-template <class T> bool tConstListIterator<T>::AtEnd() const
-{
- return (node->next == &(list.root));
-}
-
-#endif
Copied: trunk/source/tools/tMatrix.h (from rev 338, trunk/source/tools/tMatrix.hh)
===================================================================
--- trunk/source/tools/tMatrix.hh 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/tools/tMatrix.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -0,0 +1,143 @@
+//////////////////////////////////////////////////////////////////////////////
+// Copyright (C) 1993 - 2003 California Institute of Technology //
+// //
+// Read the COPYING and README files, or contact 'avida at alife.org', //
+// before continuing. SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE. //
+//////////////////////////////////////////////////////////////////////////////
+
+/*
+ tMatrix.h
+ Matrix Templates
+
+ Constructor:
+ tMatrix( int rows, int cols )
+ tMatrix( const tMatrix & rhs )
+
+ Interface:
+ tMatrix & operator= ( const tMatrix & rhs )
+
+ unsigned int GetNumRows () const
+ unsigned int GetNumCols () const
+ returns the size of the array
+
+ const T& ElementAt ( const int row, col ) const
+ T& ElementAt ( const int row, col )
+ const T& operator() ( const int row, col ) const
+ T& operator() ( const int row, col )
+ return the element at position in the matrix
+
+ const tArray<T>& operator[] ( const int row ) const
+ tArray<T>& operator[] ( const int row )
+ return the array at the row in the matrix.
+
+
+*/
+
+#ifndef TMATRIX_HH
+#define TMATRIX_HH
+
+#include <assert.h>
+
+#ifndef TARRAY_HH
+#include "tArray.h"
+#endif
+
+/**
+ * This class provides a matrix template.
+ **/
+
+template <class T> class tArray; // access
+
+template <class T> class tMatrix {
+protected:
+ // Internal Variables
+ tArray<T> * data; // Data Elements
+ int num_rows;
+public:
+ int GetNumRows() const { return num_rows; }
+ int GetNumCols() const { return data[0].GetSize(); }
+
+ void ResizeClear(const int _rows, const int _cols){
+ if (_rows != GetNumRows()) {
+ num_rows = _rows;
+ assert(_rows > 0); // Invalid size specified for matrix resize
+ if( data != NULL ) delete [] data; // remove old data if exists
+ data = new tArray<T>[_rows]; // Allocate block for data
+ assert(data != NULL); // Memory Allocation Error: Out of Memory?
+ }
+ for (int i = 0; i < GetNumRows(); i++) data[i].ResizeClear(_cols);
+ }
+
+ void Resize(int _rows, int _cols) {
+ // Rows and cols must be > 0
+ assert(_rows > 0 && _cols > 0); // Invalid size specified for matrix resize
+
+ if( data != NULL ) {
+ tArray<T> * new_data = new tArray<T>[_rows];
+ for (int i = 0; i < GetNumRows() && i < _rows; i++) {
+ new_data[i] = data[i];
+ }
+ delete [] data; // remove old data if exists
+ data = new_data;
+ } else {
+ data = new tArray<T>[_rows]; // Allocate block for data
+ }
+ assert(data != NULL); // Memory Allocation Error: Out of Memory?
+ num_rows = _rows;
+
+ for (int i = 0; i < _rows; i++) data[i].Resize(_cols);
+ }
+
+ T & ElementAt(int _row, int _col) { return data[_row][_col]; }
+ const T & ElementAt(int _row, int _col) const { return data[_row][_col]; }
+
+ T & operator()(int _r, int _c) { return ElementAt(_r, _c); }
+ const T & operator()(int _r, int _c) const { return ElementAt(_r, _c); }
+
+ tArray<T> & operator[](int row) { return data[row]; }
+ const tArray<T> & operator[](int row) const { return data[row]; }
+
+ void SetAll(const T & value) {
+ for (int i = 0; i < num_rows; i++) {
+ data[i].SetAll(value);
+ }
+ }
+
+
+public:
+ // Default Constructor
+ explicit tMatrix() : data(NULL), num_rows(0) { ResizeClear(1,1); }
+
+ // Constructor
+ explicit tMatrix(const int _rows, const int _cols) :
+ data(NULL), num_rows(0) {
+ ResizeClear(_rows, _cols);
+ }
+
+ // Assingment Operator
+ tMatrix & operator= (const tMatrix<T> & rhs){
+ if( GetNumRows() != rhs.GetNumRows() || GetNumCols() != rhs.GetNumCols()) {
+ ResizeClear(rhs.GetNumRows(), rhs.GetNumCols());
+ }
+ for (int row = 0; row < GetNumRows(); row++) {
+ for (int col = 0; col < GetNumCols(); col++) {
+ data[row][col] = rhs.data[row][col];
+ }
+ }
+ return *this;
+ }
+
+ // Copy constructor
+ //explicit tMatrix(const tMatrix & rhs) : data(NULL), num_rows(0) {
+ // this->operator=(rhs);
+ //}
+
+ tMatrix(const tMatrix & rhs) : data(NULL), num_rows(0) {
+ this->operator=(rhs);
+ }
+
+ // Destructor
+ virtual ~tMatrix(){ if(data!=NULL) delete [] data; }
+};
+
+#endif // TARRAY_HH
Deleted: trunk/source/tools/tMatrix.hh
===================================================================
--- trunk/source/tools/tMatrix.hh 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/tools/tMatrix.hh 2005-10-10 23:44:52 UTC (rev 339)
@@ -1,143 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// Copyright (C) 1993 - 2003 California Institute of Technology //
-// //
-// Read the COPYING and README files, or contact 'avida at alife.org', //
-// before continuing. SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE. //
-//////////////////////////////////////////////////////////////////////////////
-
-/*
- tMatrix.hh
- Matrix Templates
-
- Constructor:
- tMatrix( int rows, int cols )
- tMatrix( const tMatrix & rhs )
-
- Interface:
- tMatrix & operator= ( const tMatrix & rhs )
-
- unsigned int GetNumRows () const
- unsigned int GetNumCols () const
- returns the size of the array
-
- const T& ElementAt ( const int row, col ) const
- T& ElementAt ( const int row, col )
- const T& operator() ( const int row, col ) const
- T& operator() ( const int row, col )
- return the element at position in the matrix
-
- const tArray<T>& operator[] ( const int row ) const
- tArray<T>& operator[] ( const int row )
- return the array at the row in the matrix.
-
-
-*/
-
-#ifndef TMATRIX_HH
-#define TMATRIX_HH
-
-#include <assert.h>
-
-#ifndef TARRAY_HH
-#include "tArray.hh"
-#endif
-
-/**
- * This class provides a matrix template.
- **/
-
-template <class T> class tArray; // access
-
-template <class T> class tMatrix {
-protected:
- // Internal Variables
- tArray<T> * data; // Data Elements
- int num_rows;
-public:
- int GetNumRows() const { return num_rows; }
- int GetNumCols() const { return data[0].GetSize(); }
-
- void ResizeClear(const int _rows, const int _cols){
- if (_rows != GetNumRows()) {
- num_rows = _rows;
- assert(_rows > 0); // Invalid size specified for matrix resize
- if( data != NULL ) delete [] data; // remove old data if exists
- data = new tArray<T>[_rows]; // Allocate block for data
- assert(data != NULL); // Memory Allocation Error: Out of Memory?
- }
- for (int i = 0; i < GetNumRows(); i++) data[i].ResizeClear(_cols);
- }
-
- void Resize(int _rows, int _cols) {
- // Rows and cols must be > 0
- assert(_rows > 0 && _cols > 0); // Invalid size specified for matrix resize
-
- if( data != NULL ) {
- tArray<T> * new_data = new tArray<T>[_rows];
- for (int i = 0; i < GetNumRows() && i < _rows; i++) {
- new_data[i] = data[i];
- }
- delete [] data; // remove old data if exists
- data = new_data;
- } else {
- data = new tArray<T>[_rows]; // Allocate block for data
- }
- assert(data != NULL); // Memory Allocation Error: Out of Memory?
- num_rows = _rows;
-
- for (int i = 0; i < _rows; i++) data[i].Resize(_cols);
- }
-
- T & ElementAt(int _row, int _col) { return data[_row][_col]; }
- const T & ElementAt(int _row, int _col) const { return data[_row][_col]; }
-
- T & operator()(int _r, int _c) { return ElementAt(_r, _c); }
- const T & operator()(int _r, int _c) const { return ElementAt(_r, _c); }
-
- tArray<T> & operator[](int row) { return data[row]; }
- const tArray<T> & operator[](int row) const { return data[row]; }
-
- void SetAll(const T & value) {
- for (int i = 0; i < num_rows; i++) {
- data[i].SetAll(value);
- }
- }
-
-
-public:
- // Default Constructor
- explicit tMatrix() : data(NULL), num_rows(0) { ResizeClear(1,1); }
-
- // Constructor
- explicit tMatrix(const int _rows, const int _cols) :
- data(NULL), num_rows(0) {
- ResizeClear(_rows, _cols);
- }
-
- // Assingment Operator
- tMatrix & operator= (const tMatrix<T> & rhs){
- if( GetNumRows() != rhs.GetNumRows() || GetNumCols() != rhs.GetNumCols()) {
- ResizeClear(rhs.GetNumRows(), rhs.GetNumCols());
- }
- for (int row = 0; row < GetNumRows(); row++) {
- for (int col = 0; col < GetNumCols(); col++) {
- data[row][col] = rhs.data[row][col];
- }
- }
- return *this;
- }
-
- // Copy constructor
- //explicit tMatrix(const tMatrix & rhs) : data(NULL), num_rows(0) {
- // this->operator=(rhs);
- //}
-
- tMatrix(const tMatrix & rhs) : data(NULL), num_rows(0) {
- this->operator=(rhs);
- }
-
- // Destructor
- virtual ~tMatrix(){ if(data!=NULL) delete [] data; }
-};
-
-#endif // TARRAY_HH
Copied: trunk/source/tools/tMemTrack.h (from rev 338, trunk/source/tools/tMemTrack.hh)
Deleted: trunk/source/tools/tMemTrack.hh
===================================================================
--- trunk/source/tools/tMemTrack.hh 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/tools/tMemTrack.hh 2005-10-10 23:44:52 UTC (rev 339)
@@ -1,43 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// Copyright (C) 1993 - 2003 California Institute of Technology //
-// //
-// Read the COPYING and README files, or contact 'avida at alife.org', //
-// before continuing. SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE. //
-//////////////////////////////////////////////////////////////////////////////
-
-#ifndef TMEM_TRACK_HH
-#define TMEM_TRACK_HH
-
-template <class T> class tMemTrack {
-private:
- static int obj_count;
-public:
- // These "New" commands can only be used with no arguments.
- static T * New() {
- obj_count++;
- return new T;
- }
- static T * New(int count) {
- obj_count += count;
- return new T[count];
- }
-
- static void Free(T * ptr) {
- obj_count--;
- free ptr;
- }
- static void Free(T * ptr, int count) {
- obj_count -= count;
- free [] ptr;
- }
-
- // This New and Free just help keep track of things handled elsewhere...
- static void MarkNew() { obj_count++; }
- static void MarkFree() { obj_count--; }
-
-
- // And some methods to keep track of what's going on...
- static int GetCount() { return obj_count; }
-};
-
-#endif
Modified: trunk/source/tools/tObjectFactory.h
===================================================================
--- trunk/source/tools/tObjectFactory.h 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/tools/tObjectFactory.h 2005-10-10 23:44:52 UTC (rev 339)
@@ -11,13 +11,13 @@
#define TOBJECTFACTORY_H
#ifndef TDICTIONARY_HH
-#include "tDictionary.hh"
+#include "tDictionary.h"
#endif
#ifndef TARRAY_HH
-#include "tArray.hh"
+#include "tArray.h"
#endif
#ifndef TLIST_HH
-#include "tList.hh"
+#include "tList.h"
#endif
class cString;
Copied: trunk/source/tools/tVector.h (from rev 338, trunk/source/tools/tVector.hh)
Deleted: trunk/source/tools/tVector.hh
===================================================================
--- trunk/source/tools/tVector.hh 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/tools/tVector.hh 2005-10-10 23:44:52 UTC (rev 339)
@@ -1,165 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// Copyright (C) 1993 - 2003 California Institute of Technology //
-// //
-// Read the COPYING and README files, or contact 'avida at alife.org', //
-// before continuing. SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE. //
-//////////////////////////////////////////////////////////////////////////////
-
-#ifndef TVECTOR_HH
-#define TVECTOR_HH
-
-/**
- * This class provides a vector template.
- **/
-
-template <class T> class tVector {
-private:
- T * _data;
- int _size;
- int _capacity;
- int _capIncrement;
-
-public:
- tVector(void): _size(0), _capacity(1), _capIncrement(-1) {
- _data = new T[_capacity];
- #ifdef EXCEPTION_HANDLING
- if(_data == NULL) throw InsufficientMemory();
- #endif
- }
-
- tVector(int cap, int incr = -1): _size(0), _capacity(cap),
- _capIncrement(incr){
- _data = new T[_capacity];
- #ifdef EXCEPTION_HANDLING
- if(_data == NULL) throw InsufficientMemory();
- #endif
- }
-
-
- tVector(const tVector &v): _size(v._size), _capacity(v._capacity),
- _capIncrement(v._capIncrement)
- {
- _data = new T[_capacity];
- #ifdef EXCEPTION_HANDLING
- if(_data == NULL) throw InsufficientMemory();
- #endif
- for(int i = 0; i < _size; i++) {
- _data[i] = v._data[i];
- }
- }
-
- ~tVector() {
- if(_data) delete [] _data;
- }
-
-public:
- int Size(void) const {
- return _size;
- }
-
- int Capacity(void) const {
- return _capacity;
- }
-
- void Add(T data) {
- if(Size() + 1 > Capacity()) { // if we have to allocate new space, do so
- T* newdata;
- if(_capIncrement == -1) {
- newdata = new T[Capacity() * 2];
- #ifdef EXCEPTION_HANDLING
- if(newdata == NULL) throw InsufficientMemory();
- #endif
- _capacity = Capacity() * 2;
- }
- else {
- newdata = new T[Capacity() + _capIncrement];
- #ifdef EXCEPTION_HANDLING
- if(newdata == NULL) throw InsufficientMemory();
- #endif
- _capacity = Capacity() + _capIncrement;
- }
-
- for(int i = 0; i < Size(); i++) {
- newdata[i] = _data[i];
- }
- newdata[_size++] = data;
- delete [] _data;
- _data = newdata;
- return;
- }
- else { // no need to allocate new data
- _data[_size++] = data;
- return;
- }
- }
-
- void Remove(T data) {
- int i, j;
- for(i = 0; _data[i] != data && i < Size(); i++);
- if(i < Size()) {
- T *newdata = new T[Capacity()];
- for(j = 0; j < i; j++) {
- newdata[j] = _data[j];
- }
- for(; j < Size() - 1; j++) {
- newdata[j] = _data[j + 1];
- }
- delete [] _data;
- _data = newdata;
- --_size;
- return;
- }
- return;
- }
-
- void RemoveAt(int idx) {
- int i, j;
- if(idx >= 0 && idx < Size()) {
- T *newdata = new T[Capacity()];
- for(i = 0; i < idx; i++) {
- newdata[i] = _data[i];
- }
- for(; i < Size() - 1; i++) {
- newdata[i] = _data[i + 1];
- }
- delete [] _data;
- _data = newdata;
- --_size;
- return;
- }
- return;
- }
-
- void Clear(void) {
- delete [] _data;
- _data = new T[Capacity()];
- _size = 0;
- }
-
-public:
- T& operator[](int idx) {
- assert( idx >= 0);
- assert( idx < Size());
- if(idx >= 0 && idx < Size()) { // it is in range
- return _data[idx];
- }
- #ifdef EXCEPTION_HANDLING
- throw IndexOutofRangeError(idx);
- #endif
- return _data[0];
- }
-
- T operator[](int idx) const {
- assert( idx >= 0);
- assert( idx < Size());
- if(idx >= 0 && idx < Size()) {
- return _data[idx];
- }
- #ifdef EXCEPTION_HANDLING
- throw IndexOutofRangeError(idx);
- #endif
- return _data[0];
- }
-};
-
-#endif
Deleted: trunk/source/tools/tools.cc
===================================================================
--- trunk/source/tools/tools.cc 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/tools/tools.cc 2005-10-10 23:44:52 UTC (rev 339)
@@ -1,55 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// Copyright (C) 1993 - 2001 California Institute of Technology //
-// //
-// Read the COPYING and README files, or contact 'avida at alife.org', //
-// before continuing. SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE. //
-//////////////////////////////////////////////////////////////////////////////
-
-#ifndef TOOLS_HH
-#include "tools.hh"
-#endif
-
-#include <iostream>
-#include <errno.h>
-#include <sys/stat.h>
-#include <stdio.h>
-
-#ifndef STRING_HH
-#include "cString.h"
-#endif
-
-#ifdef WIN32
-# ifndef WIN32_MKDIR_HACK_HH
-# include "win32_mkdir_hack.hh"
-# endif
-#endif
-
-cRandom g_random;
-
-using namespace std;
-
-bool cTools::MkDir(const cString & dirname, bool verbose)
-{
- if (verbose) cout << "Checking for directory '" << dirname << "'..." << flush;
-
- FILE * fp = fopen ( dirname(), "r" );
- if (fp == 0) {
- if (errno == ENOENT) {
- if (verbose) cout << " not found, creating..." << flush;
- if (mkdir( dirname(), (S_IRWXU|S_IRWXG|S_IRWXO) )) {
- if (verbose)
- cerr << endl << "Warning: Failed to create directory '" << dirname << "'." << endl;
- return false;
- }
-
- if (verbose) cout << " done." << endl;
- return true;
- }
-
- if (verbose) cout << "Warning: Failed to open '" << dirname << "'." << endl;
- return false;
- }
-
- if (verbose) cout << " found." << endl;
- return true;
-}
Deleted: trunk/source/tools/tools.hh
===================================================================
--- trunk/source/tools/tools.hh 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/tools/tools.hh 2005-10-10 23:44:52 UTC (rev 339)
@@ -1,30 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// Copyright (C) 1993 - 2003 California Institute of Technology //
-// //
-// Read the COPYING and README files, or contact 'avida at alife.org', //
-// before continuing. SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE. //
-//////////////////////////////////////////////////////////////////////////////
-
-// This file is for misc. objects which are of general use...
-
-#ifndef TOOLS_HH
-#define TOOLS_HH
-
-#ifndef RANDOM_HH
-#include "cRandom.h"
-#endif
-
-extern cRandom g_random;
-
-/*
- * Filesystem tools...
- */
-
-class cString;
-
-class cTools {
-public:
- static bool MkDir(const cString & dirname, bool verbose=false);
-};
-
-#endif
Modified: trunk/source/tools/tools.pri
===================================================================
--- trunk/source/tools/tools.pri 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/tools/tools.pri 2005-10-10 23:44:52 UTC (rev 339)
@@ -15,16 +15,16 @@
$$TOOLS_HH/cString.h \
$$TOOLS_HH/cStringList.h \
$$TOOLS_HH/cStringUtil.h \
- $$TOOLS_HH/tArray.hh \
- $$TOOLS_HH/tBuffer.hh \
- $$TOOLS_HH/tDictionary.hh \
- $$TOOLS_HH/tList.hh \
- $$TOOLS_HH/tMatrix.hh \
-# $$TOOLS_HH/tMemTrack.hh \
- $$TOOLS_HH/tools.hh \
- $$TOOLS_HH/tVector.hh \
- $$TOOLS_HH/uint.hh \
- $$TOOLS_HH/weighted_index.hh \
+ $$TOOLS_HH/tArray.h \
+ $$TOOLS_HH/tBuffer.h \
+ $$TOOLS_HH/tDictionary.h \
+ $$TOOLS_HH/tList.h \
+ $$TOOLS_HH/tMatrix.h \
+# $$TOOLS_HH/tMemTrack.h \
+ $$TOOLS_HH/cTools.h \
+ $$TOOLS_HH/tVector.h \
+ $$TOOLS_HH/cUInt.h \
+ $$TOOLS_HH/cWeightedIndex.h \
$$TOOLS_HH/win32_mkdir_hack.hh
SOURCES += $$TOOLS_CC/cBlockStruct.cc \
@@ -60,6 +60,6 @@
$$TOOLS_CC/cStringIterator.cc \
$$TOOLS_CC/cStringList.cc \
$$TOOLS_CC/cStringUtil.cc \
- $$TOOLS_CC/tools.cc \
- $$TOOLS_CC/weighted_index.cc
+ $$TOOLS_CC/cTools.cc \
+ $$TOOLS_CC/cWeightedIndex.cc
}
Deleted: trunk/source/tools/uint.hh
===================================================================
--- trunk/source/tools/uint.hh 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/tools/uint.hh 2005-10-10 23:44:52 UTC (rev 339)
@@ -1,785 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// Copyright (C) 1993 - 2003 California Institute of Technology //
-// //
-// Read the COPYING and README files, or contact 'avida at alife.org', //
-// before continuing. SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE. //
-//////////////////////////////////////////////////////////////////////////////
-
-#ifndef UINT_HH
-#define UINT_HH
-
-#include <stdio.h>
-
-#ifndef UCHAR
-#define UCHAR unsigned char
-#endif
-
-// Should this just use a long? For testing only...
-#define LONG_C_UINT
-
-#ifdef LONG_C_UINT
-class cUInt {
-private:
- long value;
- int size;
-public:
- inline cUInt() { size = 0; value = 0; }
- inline cUInt(int in_size) { size = in_size, value = 0; }
- inline cUInt(int in_size, int in_value) { size = in_size, value = in_value; }
- inline ~cUInt() {;}
-
- inline void Print() const { printf ("%ld", value); }
- inline int AsInt() const { return (int) value; }
- inline long AsLong() const { return value; }
-
- inline void ShiftLeft(int num_bytes = 1) { value = value << (8 * num_bytes);}
- inline void ShiftRight(int num_bytes = 1){ value = value >> (8 * num_bytes);}
-
- inline cUInt& operator=(const UCHAR in_char) {
- value = (long) in_char;
- return *this;
- }
- inline cUInt& operator=(const int in_int) {
- value = (long) in_int;
- return *this;
- }
- inline cUInt& operator=(const cUInt& in_cUInt) {
- value = in_cUInt.AsLong();
- return *this;
- }
-
- inline cUInt& operator*=(const UCHAR in_char){
- value *= (long) in_char;
- return *this;
- }
-
- inline cUInt& operator+=(const int in_int) {
- value += (long) in_int;
- return *this;
- }
-
- inline cUInt& operator-=(const int in_int) {
- value -= in_int;
- return *this;
- }
-
- inline cUInt& operator*=(const int in_int) {
- value *= in_int;
- return *this;
- }
-
- inline cUInt& operator/=(const int in_int) {
- value /= in_int;
- return *this;
- }
-
- inline cUInt& operator%=(const int in_int) {
- value %= in_int;
- return *this;
- }
-
-
- inline cUInt& operator+=(const cUInt& in_cUInt) {
- value += in_cUInt.AsLong();
- return *this;
- }
-
- inline cUInt& operator-=(const cUInt& in_cUInt) {
- value -= in_cUInt.AsLong();
- return *this;
- }
-
- inline cUInt& operator*=(const cUInt& in_cUInt) {
- value *= in_cUInt.AsLong();
- return *this;
- }
-
- inline cUInt& operator/=(const cUInt& in_cUInt) {
- value /= in_cUInt.AsLong();
- return *this;
- }
-
- inline cUInt& operator%=(const cUInt& in_cUInt) {
- value %= in_cUInt.AsLong();
- return *this;
- }
-
-
- inline cUInt& operator+(const int in_int) {
- cUInt * temp = new cUInt;
- *temp = *this;
- *temp += in_int;
- return *temp;
- }
- inline cUInt& operator-(const int in_int) {
- cUInt * temp = new cUInt;
- *temp = *this;
- *temp -= in_int;
- return *temp;
- }
- inline cUInt& operator*(const int in_int) {
- cUInt * temp = new cUInt;
- *temp = *this;
- *temp *= in_int;
- return *temp;
- }
- inline cUInt& operator/(const int in_int) {
- cUInt * temp = new cUInt;
- *temp = *this;
- *temp /= in_int;
- return *temp;
- }
- inline cUInt& operator%(const int in_int) {
- cUInt * temp = new cUInt;
- *temp = *this;
- *temp %= in_int;
- return *temp;
- }
-
- inline cUInt& operator+(const cUInt& in_cUInt) {
- cUInt * temp = new cUInt;
- *temp = *this;
- *temp += in_cUInt;
- return *temp;
- }
- inline cUInt& operator-(const cUInt& in_cUInt) {
- cUInt * temp = new cUInt;
- *temp = *this;
- *temp -= in_cUInt;
- return *temp;
- }
- inline cUInt& operator*(const cUInt& in_cUInt) {
- cUInt * temp = new cUInt;
- *temp = *this;
- *temp *= in_cUInt;
- return *temp;
- }
- inline cUInt& operator/(const cUInt& in_cUInt) {
- cUInt * temp = new cUInt;
- *temp = *this;
- *temp /= in_cUInt;
- return *temp;
- }
- inline cUInt& operator%(const cUInt& in_cUInt) {
- cUInt * temp = new cUInt;
- *temp = *this;
- *temp %= in_cUInt;
- return *temp;
- }
-
- inline int operator==(const cUInt& in_cUInt) const {
- return (value == in_cUInt.AsLong());
- }
-
- inline int operator<(const cUInt& in_cUInt) const {
- return (value < in_cUInt.AsLong());
- }
-
- inline int operator<=(const cUInt& in_cUInt) const {
- return (value <= in_cUInt.AsLong());
- }
-
- inline int operator>(const cUInt& in_cUInt) const {
- return (value > in_cUInt.AsLong());
- }
-
- inline int operator>=(const cUInt& in_cUInt) const {
- return (value >= in_cUInt.AsLong());
- }
-
-};
-#endif
-
-
-#ifndef LONG_C_UINT
-
-/**
- * This class constructs an arbitrary (pre-set) large integer. Not all of the
- * possible operators have been added yet; they will be as they are needed.
- **/
-
-class cUInt {
-private:
- UCHAR * value;
- int size;
-
-public:
- inline cUInt();
- inline cUInt(int in_size);
- inline cUInt(int in_size, int in_value);
- inline ~cUInt();
-
- inline void Resize(int new_size);
- inline void PrintBytes() const;
- inline void Print(cUInt * input_thing = NULL) const;
- inline int AsInt() const;
- inline long AsLong() const; //Do not use!! Assumes 8 byte longs... for tests.
-
- inline int GetSize() const { return size; }
- inline int GetSizeUsed() const;
- inline UCHAR GetByte(int byte_num) const { return value[byte_num]; }
- inline void SetByte(int byte_num, UCHAR in_char) {value[byte_num] = in_char;}
-
- inline void ShiftLeft(int num_bytes = 1);
- inline void ShiftRight(int num_bytes = 1);
-
- inline cUInt& operator=(const UCHAR in_char);
- inline cUInt& operator=(const int in_int);
- inline cUInt& operator=(const cUInt& in_cUInt);
-
- inline cUInt& operator*=(const UCHAR in_char);
-
- inline cUInt& operator+=(const int in_int);
- inline cUInt& operator-=(const int in_int);
- inline cUInt& operator*=(const int in_int);
- inline cUInt& operator/=(const int in_int);
- inline cUInt& operator%=(const int in_int);
-
- inline cUInt& operator+=(const cUInt& in_cUInt);
- inline cUInt& operator-=(const cUInt& in_cUInt);
- inline cUInt& operator*=(const cUInt& in_cUInt);
- inline cUInt& operator/=(const cUInt& in_cUInt);
- inline cUInt& operator%=(const cUInt& in_cUInt);
-
- inline int operator==(const cUInt& in_cUInt) const;
- inline int operator<( const cUInt& in_cUInt) const;
- inline int operator<=(const cUInt& in_cUInt) const;
- inline int operator>( const cUInt& in_cUInt) const;
- inline int operator>=(const cUInt& in_cUInt) const;
-
- inline cUInt& operator+(const int in_int) {
- cUInt * temp = new cUInt;
- *temp = *this;
- *temp += in_int;
- return *temp;
- }
- inline cUInt& operator-(const int in_int) {
- cUInt * temp = new cUInt;
- *temp = *this;
- *temp -= in_int;
- return *temp;
- }
- inline cUInt& operator*(const int in_int) {
- cUInt * temp = new cUInt;
- *temp = *this;
- *temp *= in_int;
- return *temp;
- }
- inline cUInt& operator/(const int in_int) {
- cUInt * temp = new cUInt;
- *temp = *this;
- *temp /= in_int;
- return *temp;
- }
- inline cUInt& operator%(const int in_int) {
- cUInt * temp = new cUInt;
- *temp = *this;
- *temp %= in_int;
- return *temp;
- }
-
- inline cUInt& operator+(const cUInt& in_cUInt) {
- cUInt * temp = new cUInt;
- *temp = *this;
- *temp += in_cUInt;
- return *temp;
- }
- inline cUInt& operator-(const cUInt& in_cUInt) {
- cUInt * temp = new cUInt;
- *temp = *this;
- *temp -= in_cUInt;
- return *temp;
- }
- inline cUInt& operator*(const cUInt& in_cUInt) {
- cUInt * temp = new cUInt;
- *temp = *this;
- *temp *= in_cUInt;
- return *temp;
- }
- inline cUInt& operator/(const cUInt& in_cUInt) {
- cUInt * temp = new cUInt;
- *temp = *this;
- *temp /= in_cUInt;
- return *temp;
- }
- inline cUInt& operator%(const cUInt& in_cUInt) {
- cUInt * temp = new cUInt;
- *temp = *this;
- *temp %= in_cUInt;
- return *temp;
- }
-};
-
-inline cUInt::cUInt()
-{
- int i;
- size = 10;
- value = new UCHAR[size];
- for (i = 0; i < size; i++) {
- value[i] = 0;
- }
-}
-
-inline cUInt::cUInt(int in_size)
-{
- int i;
-
- size = in_size;
- value = new UCHAR[size];
- for (i = 0; i < size; i++) {
- value[i] = 0;
- }
-}
-
-inline cUInt::cUInt(int in_size, int in_value)
-{
- int i;
-
- size = in_size;
- value = new UCHAR[size];
- for (i = 0; i < size && i < 4; i++) {
- value[i] = (UCHAR) (in_value >> (8 * i));
- }
- while (i < size) {
- value[i++] = 0;
- }
-}
-
-inline cUInt::~cUInt()
-{
- delete value;
-}
-
-inline void cUInt::Resize(int new_size)
-{
- UCHAR * new_value = new UCHAR[new_size];
-
- int i;
- for (i = 0; i < new_size && i < size; i++) {
- new_value[i] = value[i];
- }
- while (i < new_size) {
- new_value[i++] = 0;
- }
-
- delete value;
- size = new_size;
- value = new_value;
-}
-
-inline void cUInt::PrintBytes() const
-{
- int i;
-
- for (i = 0; i < GetSizeUsed(); i++) {
- printf("[%d] ", (int) value[i]);
- }
-}
-
-// This is *very* poorly written currently!
-inline void cUInt::Print(cUInt * input_thing) const
-{
- if (!input_thing) {
- cUInt * input_thing2;
- input_thing2 = new cUInt(size);
- *input_thing2 = *this;
- Print(input_thing2);
- }
- else if (input_thing->GetSizeUsed()) {
- cUInt this_num(size);
- this_num = *input_thing;
- this_num %= 10;
-
- *input_thing /= 10;
- Print(input_thing);
- printf("%01d", this_num.AsInt());
- }
-}
-
-inline int cUInt::AsInt() const
-{
- int i, ret_value = 0;
-
- for (i = 3; i >= 0; i--) {
- ret_value = ret_value << 8;
- ret_value += value[i];
- }
-
- return ret_value;
-}
-
-inline long cUInt::AsLong() const
-{
- int i;
- long ret_value = 0;
-
- for (i = 7; i >= 0; i--) {
- ret_value = ret_value << 8;
- ret_value += value[i];
- }
-
- return ret_value;
-}
-
-inline int cUInt::GetSizeUsed() const
-{
- int size_used = size, i;
- for (i = size - 1; i >= 0 && !value[i]; i--) size_used--;
- return size_used;
-}
-
-inline void cUInt::ShiftLeft(int num_bytes)
-{
- int i;
-
- // Starting at the end, copy down all the applicable bytes.
-
- for (i = size - 1; i >= num_bytes; i--) {
- value[i] = value[i - num_bytes];
- }
-
- // Now fill in all of the 'new' bytes with 0's.
-
- for (i = num_bytes - 1; i >= 0; i--) {
- value[i] = 0;
- }
-}
-
-inline void cUInt::ShiftRight(int num_bytes)
-{
- int i;
-
- // Shift over the numbers...
-
- for (i = 0; i < size - num_bytes; i++) {
- value[i] = value[i + num_bytes];
- }
-
- // And fill in 0's where applicable.
-
- for (i = size - num_bytes; i < size; i++) {
- value[i] = 0;
- }
-}
-
-inline cUInt& cUInt::operator=(const UCHAR in_char)
-{
- int i;
- value[0] = in_char;
- for (i = 1; i < size; i++) {
- value[i] = 0;
- }
-
- return *this;
-}
-
-inline cUInt& cUInt::operator=(const int in_int)
-{
- int i;
- for (i = 0; i < 4 && i < size; i++) {
- value[i] = (UCHAR) (in_int >> (8*i));
- }
- for (i = 4; i < size; i++) {
- value[i] = 0;
- }
-
- return *this;
-}
-
-inline cUInt& cUInt::operator=(const cUInt& in_cUInt)
-{
- int i;
- int size2 = in_cUInt.GetSize();
-
- for (i = 0; i < size && i < size2; i++) {
- value[i] = in_cUInt.GetByte(i);
- }
- for (i = size2; i < size; i++) {
- value[i] = 0;
- }
-
- return *this;
-}
-
-inline cUInt& cUInt::operator*=(const UCHAR in_char)
-{
- int this_byte = 0, carry = 0;
- int i;
-
- for (i = 0; i < size; i++) {
- this_byte = (int) value[i] * (int) in_char + carry;
- value[i] = this_byte & 255;
- carry = this_byte >> 8;
- }
-
- return *this;
-}
-
-inline cUInt& cUInt::operator+=(const int in_int)
-{
- cUInt add_int(4, in_int);
- operator+=(add_int);
-
- return *this;
-}
-
-inline cUInt& cUInt::operator-=(const int in_int)
-{
- cUInt sub_int(4, in_int);
- operator-=(sub_int);
-
- return *this;
-}
-
-inline cUInt& cUInt::operator*=(const int in_int)
-{
- cUInt mult_int(4, in_int);
- operator*=(mult_int);
-
- return *this;
-}
-
-inline cUInt& cUInt::operator/=(const int in_int)
-{
- cUInt div_int(4, in_int);
- operator/=(div_int);
-
- return *this;
-}
-
-inline cUInt& cUInt::operator%=(const int in_int)
-{
- cUInt mod_int(4, in_int);
- operator%=(mod_int);
-
- return *this;
-}
-
-inline cUInt& cUInt::operator+=(const cUInt& in_cUInt)
-{
- int i;
- int cur_sum = 0;
-
- // Add up sums byte by byte, carrying any remainders.
-
- for (i = 0; i < size && i < in_cUInt.GetSize(); i++) {
- cur_sum += value[i];
- cur_sum += in_cUInt.GetByte(i);
- value[i] = (UCHAR) (cur_sum & 255);
- cur_sum = cur_sum >> 8;
- }
-
- // If there is still a remainder, and room for it, continue.
-
- while (cur_sum && i < size) {
- value[i++] = (UCHAR) (cur_sum & 255);
- }
-
- return *this;
-}
-
-inline cUInt& cUInt::operator-=(const cUInt& in_cUInt)
-{
- int i;
- int next_byte = 0, byte1, byte2;
-
- for (i = 0; i < size && i < in_cUInt.GetSize(); i++) {
- byte1 = (int) value[i];
- byte2 = (int) in_cUInt.GetByte(i);
- if (byte1 + next_byte >= byte2) {
- value[i] = (UCHAR) (byte1 + next_byte - byte2);
- next_byte = 0;
- }
- else {
- value[i] = (UCHAR) (256 + byte1 + next_byte - byte2);
- next_byte = -1;
- }
- }
-
- // Check to see if there are any more effects of the carry...
-
- for (i = in_cUInt.GetSize(); i < size && next_byte < 0; i++) {
- if (value[i] + next_byte >= 0) {
- value[i] += next_byte;
- next_byte = 0;
- }
- else {
- value[i] = (UCHAR) (256 + next_byte + (int) value[i]);
- next_byte = -1;
- }
- }
-
- return *this;
-}
-
-inline cUInt& cUInt::operator*=(const cUInt& in_cUInt)
-{
- cUInt sum_cUInt(size), temp_cUInt(size);
- int i;
-
- for (i = in_cUInt.GetSize() - 1; i >= 0; i--) {
- temp_cUInt = *this;
- temp_cUInt *= in_cUInt.GetByte(i);
- sum_cUInt.ShiftLeft();
- sum_cUInt += temp_cUInt;
- }
-
- operator=(sum_cUInt);
-
- return *this;
-}
-
-inline cUInt& cUInt::operator/=(const cUInt& in_cUInt)
-{
- // Guess the approximate size of the result, and start from there.
-
- cUInt result(size + 2); // @CAO FIX THIS
-
- // Now, loops through filling in one byte of the result at a time.
-
- int cur_byte, cur_bit;
- for (cur_byte = GetSizeUsed() - in_cUInt.GetSizeUsed(); cur_byte >= 0; cur_byte--) {
- for (cur_bit = 7; cur_bit >= 0; cur_bit--) {
- cUInt cur_test(result.GetSize(), 1 << cur_bit);
- cur_test.ShiftLeft(cur_byte);
- cur_test += result;
-
- if (*this >= (cur_test * in_cUInt)) result = cur_test;
- }
- }
-
- operator=(result);
-
- return *this;
-}
-
-inline cUInt& cUInt::operator%=(const cUInt& in_cUInt)
-{
- cUInt multiple(size);
-
- multiple = *this;
- multiple /= in_cUInt;
- multiple *= in_cUInt;
- *this -= multiple;
-
- return *this;
-}
-
-/* int operator==(int in_int)
-{
- cUInt temp_int(4, in_int);
- return operator==(temp_int);
-}
-
-int operator<(int in_int)
-{
- cUInt temp_int(4, in_int);
- return operator<(temp_int);
-}
-
-int operator<=(int in_int)
-{
- cUInt temp_int(4, in_int);
- return operator<=(temp_int);
-}
-
-int operator>(int in_int)
-{
- cUInt temp_int(4, in_int);
- return operator>(temp_int);
-}
-
-int operator>=(int in_int)
-{
- cUInt temp_int(4, in_int);
- return operator>=(temp_int);
-}
-*/
-
-inline bool cUInt::operator==(const cUInt& in_cUInt) const
-{
- int i;
-
- // Make sure all of the overlaped bytes are identical.
-
- for (i = 0; i < size && i < in_cUInt.GetSize(); i++) {
- if (value[i] != in_cUInt.GetByte(i)) return false;
- }
-
- // Make sure all of the bytes one contains beyond the other are 0.
-
- for (i = in_cUInt.GetSize(); i < size; i++) {
- if (value[i]) return false;
- }
- for (i = size; i < in_cUInt.GetSize(); i++) {
- if (in_cUInt.GetByte(i)) return false;
- }
-
- return true;
-}
-
-inline bool cUInt::operator<(const cUInt& in_cUInt) const
-{
- // First check the extra digits to see if they effect things...
-
- for (int i = size; i < in_cUInt.GetSize(); i++) {
- if (in_cUInt.GetByte(i)) return true;
- }
- for (int i = in_cUInt.GetSize(); i < size; i++) {
- if (value[i]) return false;
- }
-
- // Now loop through the matching digits until there is a difference
-
- int match_size = size;
- if (size > in_cUInt.GetSize()) match_size = in_cUInt.GetSize();
-
- for (int i = match_size - 1; i >= 0; i--) {
- if (value[i] > in_cUInt.GetByte(i)) return false;
- if (value[i] < in_cUInt.GetByte(i)) return true;
- }
-
- // And if they are equal...
-
- return false;
-}
-
-inline bool cUInt::operator<=(const cUInt& in_cUInt) const
-{
- // First check the extra digits to see if they effect things...
-
- for (int i = size; i < in_cUInt.GetSize(); i++) {
- if (in_cUInt.GetByte(i)) return true;
- }
- for (int i = in_cUInt.GetSize(); i < size; i++) {
- if (value[i]) return false;
- }
-
- // Now loop through the matching digits until there is a difference
-
- int match_size = size;
- if (size > in_cUInt.GetSize()) match_size = in_cUInt.GetSize();
-
- for (int i = match_size - 1; i >= 0; i--) {
- if (value[i] > in_cUInt.GetByte(i)) return false;
- if (value[i] < in_cUInt.GetByte(i)) return true;
- }
-
- // And if they are equal...
-
- return true;
-}
-
-inline bool cUInt::operator>(const cUInt& in_cUInt) const
-{
- return !operator<=(in_cUInt);
-}
-
-inline cUInt::operator>=(const cUInt& in_cUInt) const
-{
- return !operator<(in_cUInt);
-}
-
-#endif
-
-#endif
Deleted: trunk/source/tools/weighted_index.cc
===================================================================
--- trunk/source/tools/weighted_index.cc 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/tools/weighted_index.cc 2005-10-10 23:44:52 UTC (rev 339)
@@ -1,98 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// Copyright (C) 1993 - 2002 California Institute of Technology //
-// //
-// Read the COPYING and README files, or contact 'avida at alife.org', //
-// before continuing. SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE. //
-//////////////////////////////////////////////////////////////////////////////
-
-#ifndef WEIGHTED_INDEX_HH
-#include "weighted_index.hh"
-#endif
-#include <iostream>
-
-
-using namespace std;
-
-
-cWeightedIndex::cWeightedIndex(int in_size)
- : size(in_size)
- , item_weight(size)
- , subtree_weight(size)
-{
- item_weight.SetAll(0);
- subtree_weight.SetAll(0);
-}
-
-cWeightedIndex::~cWeightedIndex()
-{
-}
-
-void cWeightedIndex::AdjustSubtree(int id, double weight_change)
-{
- subtree_weight[id] += weight_change;
- if (id != 0) {
- AdjustSubtree(GetParent(id), weight_change);
- }
-}
-
-void cWeightedIndex::SetWeight(int id, double in_weight)
-{
- const double weight_change = in_weight - item_weight[id];
- item_weight[id] = in_weight;
- AdjustSubtree(id, weight_change);
-}
-
-// This order of testing is about 10% faster than the one used below.
-// Alas, it scans the array out of bounds... For a real test we need to
-// look at timings in optimized mode.
-// int cWeightedIndex::FindPosition(double position, int root_id)
-// {
-// // Check left...
-// const int left_id = GetLeftChild(root_id);
-// if (position < subtree_weight[left_id]) {
-// return FindPosition(position, left_id);
-// }
-
-// // Then right...
-// position -= subtree_weight[left_id];
-// const int right_id = GetRightChild(root_id);
-// if (position < subtree_weight[right_id]) {
-// return FindPosition(position, right_id);
-// }
-
-// // Then just return this!
-// return root_id;
-// }
-
-int cWeightedIndex::FindPosition(double position, int root_id)
-{
-// cout << "Seeking " << position
-// << " at root " << root_id
-// << " subtree size = " << subtree_weight[root_id]
-// << " (left=" << subtree_weight[GetLeftChild(root_id)]
-// << " , right=" << subtree_weight[GetRightChild(root_id)]
-// << " , this=" << item_weight[root_id] << ")"
-// << endl;
- assert(position < subtree_weight[root_id]);
-
- // First, see if we should just return this node.
- if (position < item_weight[root_id]) {
- return root_id;
- }
-
- // If not, then see if we should search in the left subtree...
- position -= item_weight[root_id];
- const int left_id = GetLeftChild(root_id);
- assert (left_id < size);
- if (position < subtree_weight[left_id]) {
- return FindPosition(position, left_id);
- }
-
- // Otherwise we must look in the right subtree...
- position -= subtree_weight[left_id];
- const int right_id = GetRightChild(root_id);
- assert (right_id < size);
- assert (position < subtree_weight[right_id]);
- return FindPosition(position, right_id);
-}
-
Deleted: trunk/source/tools/weighted_index.hh
===================================================================
--- trunk/source/tools/weighted_index.hh 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/tools/weighted_index.hh 2005-10-10 23:44:52 UTC (rev 339)
@@ -1,48 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// Copyright (C) 1993 - 2003 California Institute of Technology //
-// //
-// Read the COPYING and README files, or contact 'avida at alife.org', //
-// before continuing. SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE. //
-//////////////////////////////////////////////////////////////////////////////
-
-#ifndef WEIGHTED_INDEX_HH
-#define WEIGHTED_INDEX_HH
-
-#ifndef TARRAY_HH
-#include "tArray.hh"
-#endif
-
-#ifndef NULL
-#define NULL 0
-#endif
-
-/**
- * This class allows indecies to be assigned a "weight" and then indexed by
- * that weight.
- **/
-
-template <class T> class tArray; // aggregate
-
-class cWeightedIndex {
-protected:
- int size;
- tArray<double> item_weight;
- tArray<double> subtree_weight;
-
- void AdjustSubtree(int id, double weight_change);
-public:
- cWeightedIndex(int in_size);
- ~cWeightedIndex();
-
- void SetWeight(int id, double weight);
- double GetWeight(int id) { return item_weight[id]; }
-
- double GetTotalWeight() { return subtree_weight[0]; }
- int FindPosition(double position, int root_id=0);
-
- int GetParent(int id) { return (id-1) / 2; }
- int GetLeftChild(int id) { return 2*id + 1; }
- int GetRightChild(int id) { return 2*id + 2; }
-};
-
-#endif
Modified: trunk/source/utils/hist_map/Makefile
===================================================================
--- trunk/source/utils/hist_map/Makefile 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/utils/hist_map/Makefile 2005-10-10 23:44:52 UTC (rev 339)
@@ -71,16 +71,16 @@
### Release Packageing ########################################################
# DO NOT DELETE
-hist_map2.o: ../../tools/tMatrix.hh ../../tools/tArray.hh
+hist_map2.o: ../../tools/tMatrix.h ../../tools/tArray.h
hist_map2.o: ../../tools/cString.h ../../tools/cFile.h
hist_map2.o: ../../tools/cInitFile.h ../../tools/cStringList.h
-hist_map2.o: ../../tools/tList.hh
+hist_map2.o: ../../tools/tList.h
../../tools/file.o: ../../tools/cFile.h ../../tools/cString.h
../../tools/file.o: ../../tools/cInitFile.h ../../tools/cStringList.h
-../../tools/file.o: ../../tools/tList.hh ../../tools/tArray.hh
+../../tools/file.o: ../../tools/tList.h ../../tools/tArray.h
../../tools/file.o: ../../tools/cGenesis.h ../../tools/cStringIterator.h
-../../tools/file.o: ../../tools/tools.hh ../../tools/cRandom.h
+../../tools/file.o: ../../tools/cTools.h ../../tools/cRandom.h
../../tools/init_file.o: ../../tools/cInitFile.h ../../tools/cStringList.h
-../../tools/init_file.o: ../../tools/tList.hh ../../tools/tArray.hh
+../../tools/init_file.o: ../../tools/tList.h ../../tools/tArray.h
../../tools/init_file.o: ../../tools/cStringIterator.h
../../tools/string.o: ../../tools/cString.h
Modified: trunk/source/utils/hist_map/hist_map.cc
===================================================================
--- trunk/source/utils/hist_map/hist_map.cc 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/utils/hist_map/hist_map.cc 2005-10-10 23:44:52 UTC (rev 339)
@@ -4,7 +4,7 @@
#include <iostream.h>
-#include "../../tools/tMatrix.hh"
+#include "../../tools/tMatrix.h"
#include "../../tools/cString.h"
#include "../../tools/cFile.h"
Modified: trunk/source/utils/hist_map/hist_map2.cc
===================================================================
--- trunk/source/utils/hist_map/hist_map2.cc 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/utils/hist_map/hist_map2.cc 2005-10-10 23:44:52 UTC (rev 339)
@@ -4,7 +4,7 @@
#include <iostream.h>
-#include "../../tools/tMatrix.hh"
+#include "../../tools/tMatrix.h"
#include "../../tools/cString.h"
#include "../../tools/cFile.h"
Modified: trunk/source/utils/task_events/task_event_gen.cc
===================================================================
--- trunk/source/utils/task_events/task_event_gen.cc 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/utils/task_events/task_event_gen.cc 2005-10-10 23:44:52 UTC (rev 339)
@@ -1,6 +1,6 @@
#include <iostream>
-#include "../../tools/tArray.hh"
+#include "../../tools/tArray.h"
#include "../../tools/cFile.h"
#include "../../tools/cRandom.h"
#include "../../tools/cString.h"
Modified: trunk/source/utils/task_events/task_event_gen.old.cc
===================================================================
--- trunk/source/utils/task_events/task_event_gen.old.cc 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/utils/task_events/task_event_gen.old.cc 2005-10-10 23:44:52 UTC (rev 339)
@@ -1,6 +1,6 @@
#include <iostream.h>
-#include "../../tools/tArray.hh"
+#include "../../tools/tArray.h"
#include "../../tools/cFile.h"
#include "../../tools/cRandom.h"
#include "../../tools/cString.h"
Modified: trunk/source/viewers/text_window.hh
===================================================================
--- trunk/source/viewers/text_window.hh 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/source/viewers/text_window.hh 2005-10-10 23:44:52 UTC (rev 339)
@@ -9,7 +9,7 @@
#define VIEW_TEXT_WINDOW_HH
#include <assert.h>
-#include "tools.hh"
+#include "cTools.h"
// class cTextWindow;
Modified: trunk/status.xml
===================================================================
--- trunk/status.xml 2005-10-08 02:02:38 UTC (rev 338)
+++ trunk/status.xml 2005-10-10 23:44:52 UTC (rev 339)
@@ -549,7 +549,7 @@
the moment this was much easier.
</action>
<action dev="CAO" type="update" context="internal">
- Cut down on the number of includes from tools.hh; most of them are
+ Cut down on the number of includes from cTools.h; most of them are
not required.
</action>
<action dev="CAO" type="update" context="internal">
@@ -863,7 +863,7 @@
measurements.
</action>
<action dev="CAO" type="update" context="internal">
- Moved task_buffer.?? to the more generic template tBuffer.hh and placed
+ Moved task_buffer.?? to the more generic template tBuffer.h and placed
it in tools.
</action>
<action dev="CAO" type="add" context="feature">
More information about the Avida-cvs
mailing list