From d9299175aac8f00fa403e10ced021d2e0a9c3604 Mon Sep 17 00:00:00 2001 From: Strahinja Val Markovic Date: Sun, 29 Apr 2012 19:56:16 -0700 Subject: [PATCH] Removing some commented out code --- cpp/LetterHash.cpp | 21 +++++++-------------- cpp/LetterHash.h | 5 ----- cpp/LetterNode.cpp | 1 + cpp/LetterNode.h | 14 +------------- cpp/tests/Completer_test.cpp | 2 ++ 5 files changed, 11 insertions(+), 32 deletions(-) diff --git a/cpp/LetterHash.cpp b/cpp/LetterHash.cpp index 9c24197e..ace88714 100644 --- a/cpp/LetterHash.cpp +++ b/cpp/LetterHash.cpp @@ -23,13 +23,14 @@ namespace YouCompleteMe const int kNumLetters = NUM_LETTERS; static const int kLettersIndexStart = 0; static const int kNumbersIndexStart = 26; -// static const int kNumbersIndexStart = 0; + bool IsUppercase( char letter ) { return 'A' <= letter && letter <= 'Z'; } + int IndexForChar( char letter ) { if ( IsUppercase( letter ) ) @@ -39,6 +40,7 @@ int IndexForChar( char letter ) return letter; } + LetterHash::LetterHash() { letters_.resize( kNumLetters ); @@ -49,6 +51,7 @@ LetterHash::LetterHash() } } + LetterHash::~LetterHash() { for ( int i = 0; i < letters_.size(); ++i ) @@ -57,6 +60,7 @@ LetterHash::~LetterHash() } } + bool LetterHash::HasLetter( char letter ) { int letter_index = IndexForChar( letter ); @@ -64,16 +68,6 @@ bool LetterHash::HasLetter( char letter ) return list; } -// const std::list< LetterNode* > LetterHash::operator[] ( char letter ) const -// { -// int letter_index = IndexForChar( letter ); -// std::list< LetterNode* > *list = letters_[ letter_index ]; -// if ( list ) -// -// return *list; -// -// return std::list< LetterNode* >(); -// } std::list< LetterNode* >& LetterHash::operator[] ( char letter ) { @@ -85,16 +79,15 @@ std::list< LetterNode* >& LetterHash::operator[] ( char letter ) letters_[ letter_index ] = new std::list< LetterNode* >(); return *letters_[ letter_index ]; - // letter_node_lists_.push_back( std::list< LetterNode* >() ); - // letters_[ letter_index ] = &letter_node_lists_.back(); - // return letter_node_lists_.back(); } + std::list< LetterNode* >* LetterHash::ListPointerAt( char letter ) { return letters_[ IndexForChar( letter ) ]; } + bool LetterHash::HasLetter( char letter ) const { return letters_[ IndexForChar( letter ) ] != NULL; diff --git a/cpp/LetterHash.h b/cpp/LetterHash.h index 19a29df6..4c08939f 100644 --- a/cpp/LetterHash.h +++ b/cpp/LetterHash.h @@ -40,8 +40,6 @@ public: LetterHash(); ~LetterHash(); - // const std::list< LetterNode* > operator[] ( char letter ) const; - bool HasLetter( char letter ); std::list< LetterNode* >& operator[] ( char letter ); @@ -53,9 +51,6 @@ public: private: std::vector< std::list< LetterNode* >* > letters_; - // TODO: remove this list, we can just create lists on the heap when we need - // them - // std::vector< std::list< LetterNode* > > letter_node_lists_; }; } // namespace YouCompleteMe diff --git a/cpp/LetterNode.cpp b/cpp/LetterNode.cpp index 71e28db6..05639d5a 100644 --- a/cpp/LetterNode.cpp +++ b/cpp/LetterNode.cpp @@ -28,6 +28,7 @@ LetterNode::LetterNode( char letter ) is_root_node = false; } + LetterNode::LetterNode( const std::string &text ) { is_uppercase = false; diff --git a/cpp/LetterNode.h b/cpp/LetterNode.h index 67dcb132..068dc52a 100644 --- a/cpp/LetterNode.h +++ b/cpp/LetterNode.h @@ -27,7 +27,6 @@ #include #include -// #include namespace YouCompleteMe { @@ -45,21 +44,13 @@ public: return is_uppercase; } -// inline const std::list< LetterNode* > NodesForLetter( char letter ) const -// { -// return letters_[ letter ]; -// } -// -// inline const std::list< LetterNode* >& NodesForLetter( char letter ) -// { -// return letters_[ letter ]; -// } inline const std::list< LetterNode* >* NodeListForLetter( char letter ) { return letters_.ListPointerAt( letter ); } + inline void PrependNodeForLetter( char letter, LetterNode* node ) { letters_[ letter ].push_front( node ); @@ -70,9 +61,6 @@ private: // TODO: rename LetterHash to LetterNodeListHash or LetterNodeListDict/Map? LetterHash letters_; std::vector< boost::shared_ptr< LetterNode > > letternode_per_text_index_; - // std::vector< std::list< LetterNode* >* > letters_; - // std::vector< std::list< LetterNode* > > letter_node_lists_; - // boost::unordered_map< std::list< LetterNode* > letters_; bool is_uppercase; bool is_root_node; }; diff --git a/cpp/tests/Completer_test.cpp b/cpp/tests/Completer_test.cpp index 95d42ca4..06c9e1ac 100644 --- a/cpp/tests/Completer_test.cpp +++ b/cpp/tests/Completer_test.cpp @@ -217,5 +217,7 @@ TEST_F( CompleterTest, SameLowercaseCandidateWins ) "Foobar" ) ); } +// TODO: tests for filepath and filetype candidate storing + } // namespace YouCompleteMe