Show List.cs syntax highlighted
using System;
using System.Drawing;
using Tao.Platform.Windows;
using Tao.OpenGl;
using System.Data;
namespace New_Study_Project
{
public class List
{
/* Definitions of the Program */
private ListNode firstNode;
private ListNode lastNode;
private int length;
/* End of Definitions of the Program */
public List()
{
this.firstNode = null;
this.lastNode = null;
}
/*******************************************************************/
/* End of the head of this Object - now the user code stuff begins */
/*******************************************************************/
public List deepCopy()
{
List copyedList = new List();
if(length == 0)
return copyedList;
ListNode currentNode = firstNode;
for(int i=0; i<length; i++)
{
copyedList.InsertAtBack(currentNode.getControlPoint);
currentNode = currentNode.Next;
}
return copyedList;
}
public void InsertAtBack(ControlPoint insertItem)
{
lock(this)
{
if(IsEmpty())
{
firstNode = lastNode = new ListNode(insertItem);
firstNode.Previous = lastNode;
firstNode.Next = lastNode;
lastNode.Next = lastNode;
lastNode.Previous = lastNode;
this.length = this.length + 1;
}
else
{
ListNode exLastNode = lastNode;
ListNode newLastNode = new ListNode(insertItem);
firstNode.Previous = newLastNode;
newLastNode.Next = firstNode;
exLastNode.Next = newLastNode;
newLastNode.Previous = exLastNode;
lastNode = newLastNode;
this.length = this.length + 1;
}
}
}
public void InsertBehind(ControlPoint currentPoint, ControlPoint insertItem)
{
ControlPoint point = currentPoint;
ListNode currentNode = firstNode;
while(currentNode.getControlPoint != point)
{
currentNode = currentNode.Next;
}
ListNode insertNode = new ListNode(insertItem, currentNode.Next, currentNode);
currentNode.Next.Previous = insertNode;
currentNode.Next = insertNode;
if(lastNode == currentNode) lastNode = insertNode;
ListNode indexNode = insertNode;
while(indexNode != lastNode)
{
indexNode = indexNode.Next;
}
this.length = this.length + 1;
}
public ListNode searchPoint(ControlPoint point)
{
ListNode currentNode = this.firstNode;
float length = this.length;
for(int i = 0; i < length; i++)
{
if(currentNode.getControlPoint == point)
{
return currentNode;
}
else
{
currentNode = currentNode.Next;
}
}
return null;
}
public void RemoveAll()
{
lock(this)
{
firstNode = null;
lastNode = null;
this.length = 0;
}
}
/*******************************************************************/
/* some function for returning values */
/*******************************************************************/
public ListNode LastNode
{
get
{
return this.lastNode;
}
}
public ListNode FirstNode
{
get
{
return this.firstNode;
}
}
public bool IsEmpty()
{
lock(this)
{
return this.firstNode == null;
}
}
public int Length
{
get
{
return this.length;
}
set
{
this.length = value;
}
}
/*******************************************************************/
/* ----------------------------------------------------------- */
/*******************************************************************/
}
}
See more files for this project here