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 )
- {
- return;
- }
- ITEM * Item = NULL;
- Item = new ITEM;
- if ( Item == NULL )
- {
- return;
- }
- Item -> Data = Data;
- if ( this -> Count == 0 )
- {
- Item -> Prev = NULL;
- Item -> Next = NULL;
- this -> First = Item;
- this -> Last = Item;
- this -> Active = Item;
- this -> Count ++;
- return;
- }
- if ( Position == 0 )
- {
- Item -> Prev = NULL;
- Item -> Next = this -> First;
- this -> First -> Prev = Item;
- this -> First = Item;
- this -> Count ++;
- return;
- }
- if ( Position == this -> Count )
- {
- Item -> Prev = this -> Last;
- Item -> Next = NULL;
- this -> Last -> Next = Item;
- this -> Last = Item;
- this -> Count ++;
- return;
- }
- 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 ++;
- return;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement