#include "DAFileDict.h" #include <stdhdrs.h> #include <strbuf.h> #include "DAFile.h" struct DAFileEntry { StrBuf key; DAFile* file; }; DAFileDict::DAFileDict(void) { } DAFileDict::~DAFileDict(void) { //VarArray does not delete the DAFileEntries //that it points to, and DAFileEntry does not //delete the DAFile that it points to. DAFileEntry* e; for ( int i = 0 ; i < array.Count() ; i++ ) { e = (DAFileEntry*)array.Get( i ); delete e->file; delete e; } } DAFile* DAFileDict::Get( const StrPtr& path ) { DAFileEntry* e; for ( int i = 0 ; i < array.Count() ; i++ ) { e = (DAFileEntry*)array.Get( i ); if ( path == e->key ) return e->file; } return 0x0; } bool DAFileDict::Put( const StrPtr& path, DAFile* file ) { //Prevent nulls. if ( !path.Length() ) return false; //Prevent duplicates. DAFileEntry* e; for ( int i = 0 ; i < array.Count() ; i++ ) { e = (DAFileEntry*)array.Get( i ); if ( path == e->key ) return false; } e = new DAFileEntry; e->key = path; e->file = file; array.Put( e ); return true; } int DAFileDict::Count() { return array.Count(); } DAFile* DAFileDict::Get( int i ) { if ( i >= array.Count() || i < 0 ) return 0x0; return ((DAFileEntry*)array.Get( i ))->file; }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#2 | 6299 | Sam Stafford |
Ditch the attempts at only processing lines that have already been connected to the starting file. It seemed to be causing more backtracking than anything else when the history was complex, and iterating through all files/revisions works just as well and isn't nearly as prone to duplicating work. |
||
#1 | 6297 | Sam Stafford |
Work so far on "deep annotate". Been getting a lot of questions on this lately from other people working on the same thing; might as well pool efforts. |