Readded Binary files
This commit is contained in:
@@ -1,12 +1,223 @@
|
|||||||
1
|
1
|
||||||
|
36
|
||||||
|
|
||||||
1
|
1
|
||||||
|
-10.0 -1.0 -10.0 0.0 0.0
|
||||||
|
-10.0 -1.0 10.0 2 0.0
|
||||||
|
-10.0 10.0 10.0 2 1.1
|
||||||
|
1.0 0.0 0.0
|
||||||
|
|
||||||
|
1
|
||||||
|
-10.0 -1.0 -10.0 0.0 0.0
|
||||||
|
-10.0 10.0 -10.0 0.0 1.1
|
||||||
|
-10.0 10.0 10.0 2 1.1
|
||||||
|
1.0 0.0 0.0
|
||||||
|
|
||||||
|
1
|
||||||
|
10.0 -1.0 -10.0 0.0 0.0
|
||||||
|
10.0 -1.0 10.0 2 0.0
|
||||||
|
10.0 10.0 10.0 2 1.1
|
||||||
|
-1.0 0.0 0.0
|
||||||
|
|
||||||
|
1
|
||||||
|
10.0 -1.0 -10.0 0.0 0.0
|
||||||
|
10.0 10.0 -10.0 0.0 1.1
|
||||||
|
10.0 10.0 10.0 2 1.1
|
||||||
|
-1.0 0.0 0.0
|
||||||
|
|
||||||
|
1
|
||||||
|
-10.0 -1.0 -10.0 0.0 0.0
|
||||||
|
-10.0 10.0 -10.0 0.0 1.1
|
||||||
|
-5.0 10.0 -10.0 .5 1.1
|
||||||
|
0.0 0.0 1.0
|
||||||
|
|
||||||
|
1
|
||||||
|
-10.0 -1.0 -10.0 0.0 0.0
|
||||||
|
-5.0 -1.0 -10.0 .5 0.0
|
||||||
|
-5.0 10.0 -10.0 .5 1.1
|
||||||
|
0.0 0.0 1.0
|
||||||
|
|
||||||
|
1
|
||||||
|
5.0 -1.0 -10.0 1.5 0.0
|
||||||
|
5.0 10.0 -10.0 1.5 1.1
|
||||||
|
10.0 10.0 -10.0 2 1.1
|
||||||
|
0.0 0.0 1.0
|
||||||
|
|
||||||
|
1
|
||||||
|
5.0 -1.0 -10.0 1.5 0.0
|
||||||
|
10.0 -1.0 -10.0 2 0.0
|
||||||
|
10.0 10.0 -10.0 2 1.1
|
||||||
|
0.0 0.0 1.0
|
||||||
|
|
||||||
|
1
|
||||||
|
-10.0 -1.0 10.0 0.0 0.0
|
||||||
|
-10.0 10.0 10.0 0.0 1.1
|
||||||
|
10.0 10.0 10.0 2 1.1
|
||||||
|
0.0 0.0 -1.0
|
||||||
|
|
||||||
|
1
|
||||||
|
-10.0 -1.0 10.0 0.0 0.0
|
||||||
|
10.0 -1.0 10.0 2 0.0
|
||||||
|
10.0 10.0 10.0 2 1.1
|
||||||
|
0.0 0.0 -1.0
|
||||||
|
|
||||||
|
2
|
||||||
|
-10.0 10.0 -10.0 0.0 32.0
|
||||||
|
10.0 10.0 -10.0 32.0 32.0
|
||||||
|
-10.0 10.0 10.0 0.0 0.0
|
||||||
|
0.0 -1.0 0.0
|
||||||
|
|
||||||
|
2
|
||||||
|
-10.0 10.0 10.0 0.0 0.0
|
||||||
|
10.0 10.0 10.0 32.0 0.0
|
||||||
|
10.0 10.0 -10.0 32.0 32.0
|
||||||
|
0.0 -1.0 0.0
|
||||||
|
|
||||||
0
|
0
|
||||||
-10 -10 -5 0 0
|
-10.0 -1.0 -10.0 0.0 4.0
|
||||||
-10 10 -5 0 1
|
10.0 -1.0 -10.0 4.0 4.0
|
||||||
10 -10 -5 1 0
|
-10.0 -1.0 10.0 0.0 0.0
|
||||||
|
0.0 1.0 0.0
|
||||||
|
|
||||||
|
0
|
||||||
|
-10.0 -1.0 10.0 0.0 0.0
|
||||||
|
10.0 -1.0 10.0 4.0 0.0
|
||||||
|
10.0 -1.0 -10.0 4.0 4.0
|
||||||
|
0.0 1.0 0.0
|
||||||
|
|
||||||
|
0
|
||||||
|
-5 -1 -10 1 0
|
||||||
|
-5 -1 -20 1 2
|
||||||
|
5 -1 -10 3 0
|
||||||
|
0 1 0
|
||||||
|
|
||||||
|
0
|
||||||
|
5 -1 -10 3 0
|
||||||
|
-5 -1 -20 1 2
|
||||||
|
5 -1 -20 3 2
|
||||||
|
0 1 0
|
||||||
|
|
||||||
|
1
|
||||||
|
-5 -1 -10 0 0
|
||||||
|
-5 10 -10 0 1.1
|
||||||
|
-5 -1 -20 1 0
|
||||||
|
1 0 0
|
||||||
|
|
||||||
|
1
|
||||||
|
-5 10 -10 0 1.1
|
||||||
|
-5 10 -20 1 1.1
|
||||||
|
-5 -1 -20 1 0
|
||||||
|
1 0 0
|
||||||
|
|
||||||
|
1
|
||||||
|
5 -1 -10 0 0
|
||||||
|
5 10 -10 0 1.1
|
||||||
|
5 -1 -20 1 0
|
||||||
|
-1 0 0
|
||||||
|
|
||||||
|
1
|
||||||
|
5 10 -10 0 1.1
|
||||||
|
5 10 -20 1 1.1
|
||||||
|
5 -1 -20 1 0
|
||||||
|
-1 0 0
|
||||||
|
|
||||||
|
2
|
||||||
|
-5 10 -10 8 0
|
||||||
|
-5 10 -20 8 16
|
||||||
|
5 10 -10 24 0
|
||||||
|
0 -1 0
|
||||||
|
|
||||||
|
2
|
||||||
|
5 10 -10 24 0
|
||||||
|
-5 10 -20 8 16
|
||||||
|
5 10 -20 24 16
|
||||||
|
0 -1 0
|
||||||
|
|
||||||
|
0
|
||||||
|
-10 -1 -20 0 2
|
||||||
|
10 -1 -20 4 2
|
||||||
|
-10 -1 -40 0 6
|
||||||
|
0 1 0
|
||||||
|
|
||||||
|
0
|
||||||
|
-10 -1 -40 0 6
|
||||||
|
10 -1 -40 4 6
|
||||||
|
10 -1 -20 4 2
|
||||||
|
0 1 0
|
||||||
|
|
||||||
|
1
|
||||||
|
-10 -1 -20 0 0
|
||||||
|
-10 -1 -40 2 0
|
||||||
|
-10 10 -20 0 1.1
|
||||||
|
1 0 0
|
||||||
|
|
||||||
|
1
|
||||||
|
-10 10 -20 0 1.1
|
||||||
|
-10 10 -40 2 1.1
|
||||||
|
-10 -1 -40 2 0
|
||||||
|
1 0 0
|
||||||
|
|
||||||
|
1
|
||||||
|
10 -1 -20 0 0
|
||||||
|
10 -1 -40 2 0
|
||||||
|
10 10 -20 0 1.1
|
||||||
|
-1 0 0
|
||||||
|
|
||||||
|
1
|
||||||
|
10 10 -20 0 1.1
|
||||||
|
10 10 -40 2 1.1
|
||||||
|
10 -1 -40 2 0
|
||||||
|
-1 0 0
|
||||||
|
|
||||||
|
1
|
||||||
|
-10 -1 -40 0 0
|
||||||
|
-10 10 -40 0 1.1
|
||||||
|
10 -1 -40 2 0
|
||||||
0 0 1
|
0 0 1
|
||||||
|
|
||||||
|
1
|
||||||
|
-10 10 -40 0 1.1
|
||||||
|
10 10 -40 2 1.1
|
||||||
|
10 -1 -40 2 0
|
||||||
|
0 0 1
|
||||||
|
|
||||||
|
2
|
||||||
|
-10 10 -20 0 0
|
||||||
|
10 10 -20 32 0
|
||||||
|
-10 10 -40 0 32
|
||||||
|
0 -1 0
|
||||||
|
|
||||||
|
2
|
||||||
|
-10 10 -40 0 32
|
||||||
|
10 10 -40 32 32
|
||||||
|
10 10 -20 32 0
|
||||||
|
0 -1 0
|
||||||
|
|
||||||
|
1
|
||||||
|
-10 -1 -20 0 0
|
||||||
|
-5 -1 -20 .5 0
|
||||||
|
-10 10 -20 0 1.1
|
||||||
|
0 0 -1
|
||||||
|
|
||||||
|
1
|
||||||
|
-10 10 -20 0 1.1
|
||||||
|
-5 -1 -20 .5 0
|
||||||
|
-5 10 -20 .5 1.1
|
||||||
|
0 0 -1
|
||||||
|
|
||||||
|
1
|
||||||
|
5 -1 -20 1.5 0
|
||||||
|
10 -1 -20 2 0
|
||||||
|
5 10 -20 1.5 1.1
|
||||||
|
0 0 -1
|
||||||
|
|
||||||
|
1
|
||||||
|
5 10 -20 1.5 1.1
|
||||||
|
10 -1 -20 2 0
|
||||||
|
10 10 -20 2 1.1
|
||||||
|
0 0 -1
|
||||||
|
|
||||||
|
|
||||||
3
|
3
|
||||||
groundc.tga
|
groundc.tga
|
||||||
moonc.tga
|
moonc.tga
|
||||||
|
|||||||
246
include/list.cpp
246
include/list.cpp
@@ -1,246 +0,0 @@
|
|||||||
/*
|
|
||||||
template <class ItemType>
|
|
||||||
listNode<ItemType>::listNode()
|
|
||||||
{
|
|
||||||
next = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class ItemType>
|
|
||||||
list<ItemType>::list()
|
|
||||||
{
|
|
||||||
head = NULL;
|
|
||||||
tail = NULL;
|
|
||||||
currPos = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class ItemType>
|
|
||||||
list<ItemType>::~list()
|
|
||||||
{
|
|
||||||
currPos = NULL;
|
|
||||||
while(head != NULL)
|
|
||||||
{
|
|
||||||
tail = head;
|
|
||||||
head = head->next;
|
|
||||||
delete tail;
|
|
||||||
tail = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class ItemType>
|
|
||||||
list<ItemType>::list(const list<ItemType>& rtOp)
|
|
||||||
{
|
|
||||||
head = NULL;
|
|
||||||
tail = NULL
|
|
||||||
currPos = NULL;
|
|
||||||
|
|
||||||
operator=(rtOp);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class ItemType>
|
|
||||||
void list<ItemType>::Clear()
|
|
||||||
{
|
|
||||||
while(head)
|
|
||||||
Remove(head->data);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class ItemType>
|
|
||||||
void list<ItemType>::operator=(const list<ItemType>& rtOp)
|
|
||||||
{
|
|
||||||
Clear();
|
|
||||||
|
|
||||||
listNode<ItemType> temp = rtOp.head->next;
|
|
||||||
listNode<ItemType> temp2 = NULL;
|
|
||||||
|
|
||||||
if(temp != NULL)
|
|
||||||
{
|
|
||||||
head = new listNode<ItemType>;
|
|
||||||
head->data = rtOp.head->data;
|
|
||||||
tail = head;
|
|
||||||
temp2 = head;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (temp != NULL)
|
|
||||||
{
|
|
||||||
temp2->next = new listNode<ItemType>;
|
|
||||||
temp2 = temp2->next;
|
|
||||||
temp2->data = temp->data;
|
|
||||||
temp = temp->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
tail = temp2;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class ItemType>
|
|
||||||
bool list<ItemType>::IsEmpty()
|
|
||||||
{
|
|
||||||
return head == NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class ItemType>
|
|
||||||
bool list<ItemType>::IsFull()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class ItemType>
|
|
||||||
void list<ItemType>::Insert(ItemType newItem)
|
|
||||||
{
|
|
||||||
listNode<ItemType>* temp = head;
|
|
||||||
if(head != NULL)
|
|
||||||
{
|
|
||||||
|
|
||||||
while(temp->next!= NULL && temp->data < newItem)
|
|
||||||
{
|
|
||||||
temp = temp->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(temp == head)
|
|
||||||
{
|
|
||||||
tail->next = head;
|
|
||||||
head = new listNode<ItemType>;
|
|
||||||
head->next = tail->next;
|
|
||||||
tail->next = NULL;
|
|
||||||
temp = head;
|
|
||||||
}
|
|
||||||
else if(temp->data != newItem)
|
|
||||||
{
|
|
||||||
if(temp == tail)
|
|
||||||
{
|
|
||||||
tail->next = new listNode<ItemType>;
|
|
||||||
tail = tail->next;
|
|
||||||
temp = tail;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
tail->next = temp->next;
|
|
||||||
temp = temp->next = new listNode<ItemType>;
|
|
||||||
temp->next = tail->next;
|
|
||||||
tail->next = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
temp = tail = head = new listNode<ItemType>;
|
|
||||||
tail->next = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
temp->data = newItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class ItemType>
|
|
||||||
void list<ItemType>::Remove(ItemType target)
|
|
||||||
{
|
|
||||||
if(head != NULL)
|
|
||||||
{
|
|
||||||
listNode<ItemType>* temp = head;
|
|
||||||
tail->next = head;
|
|
||||||
|
|
||||||
while(temp->next != NULL && temp->data != target)
|
|
||||||
{
|
|
||||||
tail->next = temp;
|
|
||||||
temp = temp->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(temp->data == target)
|
|
||||||
{
|
|
||||||
if(tail->next != head)
|
|
||||||
{
|
|
||||||
tail->next->next = temp->next;
|
|
||||||
delete temp;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
head = head->next;
|
|
||||||
delete tail->next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tail->next = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class ItemType>
|
|
||||||
bool list<ItemType>::PrevPosition()
|
|
||||||
{
|
|
||||||
if(currPos != head)
|
|
||||||
{
|
|
||||||
tail->next = currPos;
|
|
||||||
currPos = head;
|
|
||||||
|
|
||||||
if(currPos != tail->next)
|
|
||||||
{
|
|
||||||
while(currPos->next != tail->next)
|
|
||||||
{
|
|
||||||
currPos = currPos->next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tail->next = NULL;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class ItemType>
|
|
||||||
bool list<ItemType>::NextPosition()
|
|
||||||
{
|
|
||||||
if(currPos != tail)
|
|
||||||
{
|
|
||||||
currPos = currPos->next;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class ItemType>
|
|
||||||
void list<ItemType>::Remove()
|
|
||||||
{
|
|
||||||
if(currPos != NULL)
|
|
||||||
{
|
|
||||||
tail->next = currPos;
|
|
||||||
currPos = currPos->next;
|
|
||||||
delete tail->next;
|
|
||||||
tail->next = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class ItemType>
|
|
||||||
ItemType list<ItemType>::Retrieve()
|
|
||||||
{
|
|
||||||
if(currPos != NULL)
|
|
||||||
return currPos->data;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class ItemType>
|
|
||||||
bool list<ItemType>::IsFirstPosition()
|
|
||||||
{
|
|
||||||
return currPos == head;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class ItemType>
|
|
||||||
bool list<ItemType>::IsLastPosition()
|
|
||||||
{
|
|
||||||
return currPos == tail;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class ItemType>
|
|
||||||
void list<ItemType>::FirstPosition()
|
|
||||||
{
|
|
||||||
currPos = head;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class ItemType>
|
|
||||||
void list<ItemType>::LastPosition()
|
|
||||||
{
|
|
||||||
currPos = tail;
|
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
|
||||||
179
include/list.h
179
include/list.h
@@ -5,13 +5,15 @@
|
|||||||
|
|
||||||
#pragma warning(disable:4715)
|
#pragma warning(disable:4715)
|
||||||
|
|
||||||
|
typedef unsigned int LIST_ARRAY_INDEX_TYPE;
|
||||||
|
|
||||||
template <class ItemType>
|
template <class ItemType>
|
||||||
class listNode
|
class listNode
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
listNode();
|
listNode();
|
||||||
listNode<ItemType>* next;
|
|
||||||
ItemType data;
|
ItemType data;
|
||||||
|
listNode<ItemType>* next;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class ItemType>
|
template <class ItemType>
|
||||||
@@ -22,21 +24,22 @@ public:
|
|||||||
~list();
|
~list();
|
||||||
list(const list&);
|
list(const list&);
|
||||||
|
|
||||||
bool IsEmpty();
|
bool IsEmpty() const;
|
||||||
bool IsFull();
|
bool IsFull() const;
|
||||||
void Insert(ItemType newItem);
|
void Insert(ItemType newItem);
|
||||||
void Remove(ItemType target);
|
void Remove(ItemType target);
|
||||||
void Remove();
|
void Remove();
|
||||||
ItemType Retrieve();
|
ItemType Retrieve() const;
|
||||||
bool PrevPosition();
|
bool PrevPosition();
|
||||||
bool NextPosition();
|
bool NextPosition();
|
||||||
bool IsFirstPosition();
|
bool IsFirstPosition() const;
|
||||||
bool IsLastPosition();
|
bool IsLastPosition() const;
|
||||||
void FirstPosition();
|
void FirstPosition();
|
||||||
void LastPosition();
|
void LastPosition();
|
||||||
void Clear();
|
void Clear();
|
||||||
void operator=(const list<ItemType>&);
|
void operator=(const list<ItemType>&);
|
||||||
ItemType operator[](unsigned int);
|
ItemType operator[](LIST_ARRAY_INDEX_TYPE) const;
|
||||||
|
ItemType& operator[](LIST_ARRAY_INDEX_TYPE);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
listNode<ItemType>* head;
|
listNode<ItemType>* head;
|
||||||
@@ -75,7 +78,7 @@ template <class ItemType>
|
|||||||
list<ItemType>::list(const list<ItemType>& rtOp)
|
list<ItemType>::list(const list<ItemType>& rtOp)
|
||||||
{
|
{
|
||||||
head = NULL;
|
head = NULL;
|
||||||
tail = NULL
|
tail = NULL;
|
||||||
currPos = NULL;
|
currPos = NULL;
|
||||||
|
|
||||||
operator=(rtOp);
|
operator=(rtOp);
|
||||||
@@ -93,36 +96,39 @@ void list<ItemType>::operator=(const list<ItemType>& rtOp)
|
|||||||
{
|
{
|
||||||
Clear();
|
Clear();
|
||||||
|
|
||||||
listNode<ItemType> temp = rtOp.head->next;
|
if(!rtOp.IsEmpty())
|
||||||
listNode<ItemType> temp2 = NULL;
|
|
||||||
|
|
||||||
if(temp != NULL)
|
|
||||||
{
|
{
|
||||||
head = new listNode<ItemType>;
|
listNode<ItemType>* temp = rtOp.head->next;
|
||||||
head->data = rtOp.head->data;
|
listNode<ItemType>* temp2 = NULL;
|
||||||
tail = head;
|
|
||||||
temp2 = head;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (temp != NULL)
|
if(temp != NULL)
|
||||||
{
|
{
|
||||||
temp2->next = new listNode<ItemType>;
|
head = new listNode<ItemType>;
|
||||||
temp2 = temp2->next;
|
head->data = rtOp.head->data;
|
||||||
temp2->data = temp->data;
|
tail = head;
|
||||||
temp = temp->next;
|
temp2 = head;
|
||||||
}
|
}
|
||||||
|
|
||||||
tail = temp2;
|
while (temp != NULL)
|
||||||
|
{
|
||||||
|
temp2->next = new listNode<ItemType>;
|
||||||
|
temp2 = temp2->next;
|
||||||
|
temp2->data = temp->data;
|
||||||
|
temp = temp->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
tail = temp2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class ItemType>
|
template <class ItemType>
|
||||||
bool list<ItemType>::IsEmpty()
|
bool list<ItemType>::IsEmpty() const
|
||||||
{
|
{
|
||||||
return head == NULL;
|
return head == NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class ItemType>
|
template <class ItemType>
|
||||||
bool list<ItemType>::IsFull()
|
bool list<ItemType>::IsFull() const
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -131,46 +137,41 @@ template <class ItemType>
|
|||||||
void list<ItemType>::Insert(ItemType newItem)
|
void list<ItemType>::Insert(ItemType newItem)
|
||||||
{
|
{
|
||||||
listNode<ItemType>* temp = head;
|
listNode<ItemType>* temp = head;
|
||||||
if(head != NULL)
|
listNode<ItemType>* temp2 = NULL;
|
||||||
|
|
||||||
|
if(head == NULL)
|
||||||
{
|
{
|
||||||
|
temp = tail = head = new listNode<ItemType>;
|
||||||
while(temp->next!= NULL && temp->data < newItem)
|
|
||||||
{
|
|
||||||
temp = temp->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(temp == head)
|
|
||||||
{
|
|
||||||
tail->next = head;
|
|
||||||
head = new listNode<ItemType>;
|
|
||||||
head->next = tail->next;
|
|
||||||
tail->next = NULL;
|
|
||||||
temp = head;
|
|
||||||
}
|
|
||||||
else if(temp->data != newItem)
|
|
||||||
{
|
|
||||||
if(temp == tail)
|
|
||||||
{
|
|
||||||
tail->next = new listNode<ItemType>;
|
|
||||||
tail = tail->next;
|
|
||||||
temp = tail;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
tail->next = temp->next;
|
|
||||||
temp = temp->next = new listNode<ItemType>;
|
|
||||||
temp->next = tail->next;
|
|
||||||
tail->next = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
temp = tail = head = new listNode<ItemType>;
|
if(newItem < head->data)
|
||||||
tail->next = NULL;
|
{
|
||||||
|
temp2 = head;
|
||||||
|
temp = head = new listNode<ItemType>;
|
||||||
|
head->next = temp2;
|
||||||
|
temp2 = NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//temp = head;
|
||||||
|
while(temp->next != NULL && newItem > temp->next->data)
|
||||||
|
{
|
||||||
|
temp = temp->next;
|
||||||
|
}
|
||||||
|
temp2 = temp->next;
|
||||||
|
temp = temp->next = new listNode<ItemType>;
|
||||||
|
temp->next = temp2;
|
||||||
|
temp2 = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
temp->data = newItem;
|
temp->data = newItem;
|
||||||
|
|
||||||
|
if(temp->next == NULL)
|
||||||
|
{
|
||||||
|
tail = temp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class ItemType>
|
template <class ItemType>
|
||||||
@@ -259,20 +260,20 @@ void list<ItemType>::Remove()
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <class ItemType>
|
template <class ItemType>
|
||||||
ItemType list<ItemType>::Retrieve()
|
ItemType list<ItemType>::Retrieve() const
|
||||||
{
|
{
|
||||||
if(currPos != NULL)
|
if(currPos != NULL)
|
||||||
return currPos->data;
|
return currPos->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class ItemType>
|
template <class ItemType>
|
||||||
bool list<ItemType>::IsFirstPosition()
|
bool list<ItemType>::IsFirstPosition() const
|
||||||
{
|
{
|
||||||
return currPos == head;
|
return currPos == head;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class ItemType>
|
template <class ItemType>
|
||||||
bool list<ItemType>::IsLastPosition()
|
bool list<ItemType>::IsLastPosition() const
|
||||||
{
|
{
|
||||||
return currPos == tail;
|
return currPos == tail;
|
||||||
}
|
}
|
||||||
@@ -290,24 +291,52 @@ void list<ItemType>::LastPosition()
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <class ItemType>
|
template <class ItemType>
|
||||||
ItemType list<ItemType>::operator[](unsigned int index)
|
ItemType list<ItemType>::operator[](LIST_ARRAY_INDEX_TYPE index) const
|
||||||
{
|
{
|
||||||
if(head != NULL)
|
if(head == NULL)
|
||||||
{
|
{
|
||||||
listNode<ItemType>* temp = head;
|
//We should throw an exception here but instead I'll just return shit guess for now if somebody does this they're just fucked.
|
||||||
while(index > 0 && temp != NULL)
|
|
||||||
{
|
|
||||||
temp = temp->next;
|
|
||||||
--index;
|
|
||||||
}
|
}
|
||||||
if(temp != NULL)
|
else
|
||||||
{
|
{
|
||||||
|
listNode<ItemType>* temp = head;
|
||||||
|
LIST_ARRAY_INDEX_TYPE current;
|
||||||
|
|
||||||
|
for(current=0;current <index; current++)
|
||||||
|
{
|
||||||
|
if(temp->next == NULL)
|
||||||
|
{
|
||||||
|
temp->next = new listNode<ItemType>;
|
||||||
|
}
|
||||||
|
temp = temp->next;
|
||||||
|
}
|
||||||
return temp->data;
|
return temp->data;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class ItemType>
|
||||||
|
ItemType& list<ItemType>::operator[](LIST_ARRAY_INDEX_TYPE index)
|
||||||
|
{
|
||||||
|
if(head == NULL)
|
||||||
|
{
|
||||||
|
tail = currPos = head = new listNode<ItemType>;
|
||||||
|
return (ItemType&)(head->data);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
listNode<ItemType>* temp = head;
|
||||||
|
LIST_ARRAY_INDEX_TYPE current;
|
||||||
|
|
||||||
#include "list.cpp"
|
for(current=0;current <index; current++)
|
||||||
|
{
|
||||||
|
if(temp->next == NULL)
|
||||||
|
{
|
||||||
|
temp->next = new listNode<ItemType>;
|
||||||
|
}
|
||||||
|
temp = temp->next;
|
||||||
|
}
|
||||||
|
return (ItemType&)(temp->data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user