Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Insert( int Data, unsigned int Position )
- {
- if ( Position =< this -> Count )
- {
- ITEM * Item = NULL;
- Item = new ITEM;
- if ( Item != NULL )
- {
- Item -> Data = Data;
- if ( this -> Count == 0 )
- {
- Item -> Prev = NULL;
- Item -> Next = NULL;
- this -> First = Item;
- this -> Last = Item;
- this -> Active = Item;
- }
- else
- {
- if ( Position == 0 )
- {
- Item -> Prev = NULL;
- Item -> Next = this -> First;
- this -> First -> Prev = Item;
- this -> First = Item;
- }
- else
- {
- if ( Position == this -> Count )
- {
- Item -> Prev = this -> Last;
- Item -> Next = NULL;
- this -> Last -> Next = Item;
- this -> Last = Item;
- }
- else
- {
- if ( Position == this -> Position )
- {
- Item -> Prev = this -> Active -> Prev;
- Item -> Next = this -> Active;
- this -> Active -> Prev -> Next = Item;
- this -> Active -> Prev = Item;
- this -> Last = Item;
- }
- }
- }
- }
- this -> Count ++;
- }
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement