summaryrefslogtreecommitdiff
path: root/protocols/FacebookRM/list.hpp
diff options
context:
space:
mode:
authorVadim Dashevskiy <watcherhd@gmail.com>2012-10-12 11:52:49 +0000
committerVadim Dashevskiy <watcherhd@gmail.com>2012-10-12 11:52:49 +0000
commitef1f6f8fac28594a151c4cd811d1590cfc7ff81d (patch)
tree36160b8124640c5bfdfb8ef259d61ef71915a679 /protocols/FacebookRM/list.hpp
parent08fd5437555d0b5cab972fb3316b4cdb8f11cdae (diff)
FacebookRM: folders restructurization
git-svn-id: http://svn.miranda-ng.org/main/trunk@1887 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/FacebookRM/list.hpp')
-rw-r--r--protocols/FacebookRM/list.hpp195
1 files changed, 0 insertions, 195 deletions
diff --git a/protocols/FacebookRM/list.hpp b/protocols/FacebookRM/list.hpp
deleted file mode 100644
index 7a26aec1ec..0000000000
--- a/protocols/FacebookRM/list.hpp
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
-
-Facebook plugin for Miranda Instant Messenger
-_____________________________________________
-
-Copyright © 2009-11 Michal Zelinka, 2011-12 Robert Pösel
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-#pragma once
-
-namespace List
-{
- template< typename T > class Item
- {
- public:
- std::string key;
- T* data;
- Item< T >* prev;
- Item< T >* next;
-
- Item( )
- {
- this->data = NULL;
- this->prev = NULL;
- this->next = NULL;
- }
-
- ~Item( )
- {
- delete this->data;
- }
- };
-
- template< typename T > class List
- {
- private:
- Item< T >* first;
- Item< T >* last;
- unsigned int count;
-
- public:
- List( )
- {
- this->first = this->last = NULL;
- this->count = 0;
- }
-
- ~List( )
- {
- this->clear( );
- }
-
- Item< T >* begin( )
- {
- return first;
- }
-
- Item< T >* end( )
- {
- return last;
- }
-
- unsigned int size( )
- {
- return count;
- }
-
- bool empty( )
- {
- return ( this->first == NULL );
- }
-
- void insert( Item< T >* item )
- {
- if ( this->empty( ))
- {
- this->first = this->last = item;
- this->count = 1;
- } else { // TODO: key sorting/comparation
- item->next = this->first;
- this->first->prev = item;
- this->first = item;
- this->count++;
- }
- }
-
- void insert( std::pair< std::string, T* > item )
- {
- Item<T>* ins = new Item<T>;
- ins->key = item.first;
- ins->data = item.second;
- this->insert( ins );
- }
- void erase( std::string key )
- {
- Item< T >* help = this->first;
- while ( help != NULL )
- {
- if ( help->key.compare( key ) != 0 )
- help = help->next;
- else
- {
- if ( help == this->first )
- {
- this->first = help->next;
- if ( this->first != NULL )
- this->first->prev = NULL;
- else
- this->last = NULL;
- }
- else if ( help == this->last )
- {
- this->last = help->prev;
- if ( this->last != NULL )
- this->last->next = NULL;
- else
- this->first = NULL;
- }
- else
- {
- help->prev->next = help->next;
- help->next->prev = help->prev;
- }
- if (help != NULL)
- {
- this->count--;
- delete help;
- }
- break;
- }
- }
- }
-
- void erase( Item< T >* item )
- {
- if (item != NULL)
- erase( item->key );
- }
-
- T* find( std::string key )
- {
- Item< T >* help = this->begin( );
- while ( help != NULL )
- {
- if ( help->key.compare( key ) != 0 )
- help = help->next;
- else
- return help->data;
- }
- return NULL;
- }
-
- T* at( const unsigned int item )
- {
- if (item >= this->count)
- return NULL;
- Item< T >* help = this->begin( );
- for ( unsigned int i = 0; i < item; i++ )
- help = help->next;
- return help->item;
- }
-
- T* operator[]( const unsigned int item )
- {
- return at( item );
- }
-
- void clear( )
- {
- Item< T >* help;
- while ( this->first != NULL )
- {
- help = this->first;
- this->first = this->first->next;
- delete help;
- }
- this->last = NULL;
- this->count = 0;
- }
- };
-};