public static SortedPosList operator -(SortedPosList a, SortedPosList b) { int clonedIndex = 0; int bIndex = 0; SortedPosList clonedList = a.Clone(); while (clonedIndex < clonedList.Count() && bIndex < b.Count()) { if (clonedList[clonedIndex].Equals(b[bIndex])) { clonedList.Remove(clonedList[clonedIndex]); } else { if (clonedList[clonedIndex].Length() >= b[bIndex].Length()) { bIndex++; } else { clonedIndex++; } } } return(clonedList); }
public static SortedPosList operator -(SortedPosList sp1, SortedPosList sp2) { SortedPosList newList = sp1.Clone(); int i = 0; int j = 0; while (i < sp1.Count() && j < sp2.Count()) { if (sp1[i].Equals(sp2[j])) { newList.Remove(sp1[i]); i++; j++; } else if (sp1[i] < sp2[j]) { i++; } else if (sp1[i] > sp2[j]) { j++; } } return(newList); }
private static void test() { //Första testet från ITHS Console.WriteLine(new Position(2, 4) + new Position(1, 2) + "\n"); Console.WriteLine(new Position(2, 4) - new Position(1, 2) + "\n"); Console.WriteLine(new Position(1, 2) - new Position(3, 6) + "\n"); Console.WriteLine(new Position(3, 5) % new Position(1, 3) + "\n"); SortedPosList list1 = new SortedPosList(); SortedPosList list2 = new SortedPosList(); list1.Add(new Position(3, 7)); list1.Add(new Position(1, 4)); list1.Add(new Position(2, 6)); list1.Add(new Position(2, 3)); Console.WriteLine(list1 + "\n"); list1.Remove(new Position(2, 6)); Console.WriteLine(list1 + "\n"); list2.Add(new Position(3, 7)); list2.Add(new Position(1, 2)); list2.Add(new Position(3, 6)); list2.Add(new Position(2, 3)); Console.WriteLine((list2 + list1) + "\n"); SortedPosList circleList = new SortedPosList(); circleList.Add(new Position(1, 1)); circleList.Add(new Position(2, 2)); circleList.Add(new Position(3, 3)); Console.WriteLine(circleList.CircleContent(new Position(5, 5), 4) + "\n"); }
public static void RunGTests() { Console.WriteLine(new Position(2, 4) + new Position(1, 2) + "\n"); Console.WriteLine(new Position(2, 4) - new Position(1, 2) + "\n"); Console.WriteLine(new Position(1, 2) - new Position(3, 6) + "\n"); Console.WriteLine(new Position(3, 5) % new Position(1, 3) + "\n"); SortedPosList list1 = new SortedPosList(); SortedPosList list2 = new SortedPosList(); list1.Add(new Position(3, 7)); list1.Add(new Position(1, 4)); list1.Add(new Position(2, 6)); list1.Add(new Position(2, 3)); Console.WriteLine(list1 + "\n"); list1.Remove(new Position(2, 6)); Console.WriteLine(list1 + "\n"); list2.Add(new Position(3, 7)); list2.Add(new Position(1, 2)); list2.Add(new Position(3, 6)); list2.Add(new Position(2, 3)); Console.WriteLine((list2 + list1) + "\n"); SortedPosList circleList = new SortedPosList(); circleList.Add(new Position(1, 1)); circleList.Add(new Position(2, 2)); circleList.Add(new Position(3, 3)); Console.WriteLine(circleList.CircleContent(new Position(5, 5), 4) + "\n"); }
public static SortedPosList operator -(SortedPosList sp1, SortedPosList sp2) { SortedPosList clone = sp1.SortedPosListClone(); int i = 0, j = 0; while (i < sp1.Count() && j < sp2.Count()) { if (sp1.positions[i].Equals(sp2.positions[j])) { clone.Remove(sp1.positions[i]); i++; j++; } else if (sp1.positions[i] < sp2.positions[j]) { i++; } else { j++; } } return(clone); }
public static SortedPosList operator +(SortedPosList sp1, SortedPosList sp2) { SortedPosList mergeLists = sp1.Clone(); sp2.positionList.ForEach(pos => mergeLists.Add(pos.Clone())); return(mergeLists); }
public SortedPosList Clone() { SortedPosList clonedList = new SortedPosList(); positionList.ForEach(pos => clonedList.Add(pos.Clone())); return(clonedList); }
static void Main(string[] args) { //Console.WriteLine(new Position(2, 4) + new Position(1, 2) + "\n"); //Console.WriteLine(new Position(2, 4) - new Position(1, 2) + "\n"); //Console.WriteLine(new Position(1, 2) - new Position(3, 6) + "\n"); //Console.WriteLine(new Position(3, 5) % new Position(1, 3) + "\n"); SortedPosList list1 = new SortedPosList(); SortedPosList list2 = new SortedPosList(); list1.Add(new Position(3, 7)); list1.Add(new Position(1, 4)); list1.Add(new Position(2, 6)); list1.Add(new Position(2, 3)); Console.WriteLine(list1 + "\n"); //Console.WriteLine(new Position(1, 4) > new Position(2, 3)); //list1.Remove(new Position(2, 6)); //Console.WriteLine(list1 + "\n"); //Console.WriteLine(list1[0]); list2.Add(new Position(3, 7)); list2.Add(new Position(1, 2)); list2.Add(new Position(3, 6)); list2.Add(new Position(2, 3)); Console.WriteLine(list2 + "\n"); Console.WriteLine((list2 - list1) + "\n"); //SortedPosList circleList = new SortedPosList(); //circleList.Add(new Position(1, 1)); //circleList.Add(new Position(2, 2)); //circleList.Add(new Position(3, 3)); //Console.WriteLine(circleList.CircleContent(new Position(5, 5), 4) + "\n"); }
public SortedPosList Clone() { SortedPosList instance = new SortedPosList(); instance.posList = posList; return(instance); }
public static SortedPosList operator +(SortedPosList sp1, SortedPosList sp2) { SortedPosList newList = sp1.Clone(); for (int i = 0; i < sp2.Count(); i++) { newList.Add(sp2[i]); } return(newList); }
public SortedPosList Clone() { SortedPosList clonedList = new SortedPosList(); foreach (var position in PosList) { clonedList.Add(position.Clone()); } return(clonedList); }
public static SortedPosList operator +(SortedPosList sp1, SortedPosList sp2) { SortedPosList clone = sp1.SortedPosListClone(); foreach (var position in sp2.positions) { clone.Add(position); } return(clone); }
public SortedPosList SortedPosListClone() { SortedPosList clone = new SortedPosList(); for (int i = 0; i < Count(); i++) { clone.positions.Insert(i, positions[i].Clone()); } return(clone); }
// Overriding operators. public static SortedPosList operator +(SortedPosList sp1, SortedPosList sp2) { SortedPosList spList = sp1.Clone(); foreach (Position p in sp2.positionsList) { spList.Add(p.Clone()); } return(spList); }
public static SortedPosList operator +(SortedPosList sp1, SortedPosList sp2) { SortedPosList copy = sp1.Clone(); foreach (Position pos in sp2.PositionList) { copy.Add(pos); } return(copy); }
// Returns a deep clone of all positions in the list public SortedPosList Clone() { SortedPosList clonedList = new SortedPosList(); foreach (Position pos in sortedPosList) { clonedList.Add(pos.Clone()); } return(clonedList); }
public SortedPosList Clone() { SortedPosList copy = new SortedPosList(); foreach (Position pos in PositionList) { copy.PositionList.Add(pos.Clone()); } return(copy); }
public SortedPosList Clone() { SortedPosList cloneList = new SortedPosList(); foreach (Position p in PositionsList) { cloneList.Add(p.Clone()); } return(cloneList); }
public SortedPosList Clone() { SortedPosList newList = new SortedPosList(); for (int i = 0; i < positions.Count(); i++) { newList.Add(positions[i].Clone()); } return(newList); }
public static SortedPosList operator *(SortedPosList a, SortedPosList b) { SortedPosList result = a.Clone(); for (int i = 0; i < b.Count(); i++) { result.Remove(b[i]); } return(result); }
public SortedPosList Clone() { SortedPosList clonedList = new SortedPosList(); foreach (var pos in positionList) { var newpos = pos.Clone(); clonedList.Add(newpos); } return(clonedList); }
public static SortedPosList operator +(SortedPosList sp1, SortedPosList sp2) { SortedPosList newList = sp1.Clone(); foreach (Position p in sp2.positions) { newList.Add(p); } return(newList); }
public SortedPosList Clone() { SortedPosList cloneList = new SortedPosList(); foreach (Position p in positions) { Position posClone = p.Clone(); cloneList.Add(posClone); } return(cloneList); }
public static SortedPosList operator +(SortedPosList posList1, SortedPosList posList2) { SortedPosList instance = posList1.Clone(); foreach (Position p in posList2.posList) { instance.posList.Add(p); } return(instance); }
public static void Main(string[] args) { Console.WriteLine(new Position(2, 4) + new Position(1, 2) + "\n"); Console.WriteLine(new Position(2, 4) - new Position(1, 2) + "\n"); Console.WriteLine(new Position(1, 2) - new Position(3, 6) + "\n"); Console.WriteLine(new Position(3, 5) % new Position(1, 3) + "\n"); SortedPosList list1 = new SortedPosList(); SortedPosList list2 = new SortedPosList(); list1.Add(new Position(3, 7)); list1.Add(new Position(1, 4)); list1.Add(new Position(2, 6)); list1.Add(new Position(2, 3)); Console.WriteLine(list1 + "\n"); list1.Remove(new Position(2, 6)); Console.WriteLine(list1 + "\n"); list2.Add(new Position(3, 7)); list2.Add(new Position(1, 2)); list2.Add(new Position(3, 6)); list2.Add(new Position(2, 3)); Console.WriteLine((list2 + list1) + "\n"); SortedPosList circleList = new SortedPosList(); circleList.Add(new Position(1, 1)); circleList.Add(new Position(2, 2)); circleList.Add(new Position(3, 3)); Console.WriteLine(circleList.CircleContent(new Position(5, 5), 4) + "\n"); SortedPosList A = new SortedPosList(); A.Add(new Position(3, 7)); A.Add(new Position(1, 4)); A.Add(new Position(2, 6)); A.Add(new Position(2, 3)); SortedPosList B = new SortedPosList(); B.Add(new Position(3, 7)); B.Add(new Position(1, 2)); B.Add(new Position(3, 6)); B.Add(new Position(2, 3)); B.Add(new Position(22, 3)); B.Add(new Position(24, 3)); Console.WriteLine($"A-listan innehåller punkterna: {A}"); Console.WriteLine($"B-listan innehåller {B}"); Console.WriteLine($"A-B blir: {A-B}"); Console.WriteLine($"B-A blir: {B - A}"); }
public SortedPosList Clone() { SortedPosList newPosList = new SortedPosList(); newPosList.positionList = new List <Position>(); foreach (Position pos in positionList) { Position newPos = pos.Clone(); newPosList.positionList.Add(newPos); } return(newPosList); }
private static void WillTest() { //Egna tester. Operatorer Position pos1 = new Position(47, 14); Position pos2 = new Position(10, 18); Position pos3 = new Position(80, 64); Position pos4 = new Position(12, 5); Position pos5 = new Position(52, 14); Position pos6 = new Position(90, 14); Position pos7 = new Position(10, 18); Position pos8 = new Position(80, 64); Position pos9 = new Position(122, 5); Position pos10 = new Position(13, 14); SortedPosList list = new SortedPosList(); list.Add(pos1); list.Add(pos2); list.Add(pos3); list.Add(pos4); list.Add(pos5); SortedPosList list2 = new SortedPosList(); list2.Add(pos6); list2.Add(pos7); list2.Add(pos8); list2.Add(pos9); list2.Add(pos10); SortedPosList list3 = list - list2; SortedPosList list4 = list2 + list; list.Remove(new Position(80, 64)); list.Remove(new Position(10, 10)); list.Remove(new Position(10, 11)); // skriver ut list - list2 Console.WriteLine("list - list2 : "); for (int i = 0; i < list3.Count(); i++) { Console.WriteLine(list3[i].ToString() + ". Length: " + list3[i].Length()); } // skriver ut list2 + list Console.WriteLine("list2 + list : "); for (int i = 0; i < list4.Count(); i++) { Console.WriteLine(list4[i].ToString() + ". Length list 2 : " + list4[i].Length()); } }
static void Main(string[] args) { //Console.WriteLine(new Position(2, 4) + new Position(1, 2) + "\n"); //Console.WriteLine(new Position(2, 4) - new Position(1, 2) + "\n"); //Console.WriteLine(new Position(1, 2) - new Position(3, 6) + "\n"); //Console.WriteLine(new Position(3, 5) % new Position(1, 3) + "\n"); //SortedPosList list1 = new SortedPosList(); //SortedPosList list2 = new SortedPosList(); //list1.Add(new Position(3, 7)); //list1.Add(new Position(1, 4)); //list1.Add(new Position(2, 6)); //list1.Add(new Position(2, 3)); //Console.WriteLine(list1 + "\n"); //list1.Remove(new Position(2, 6)); //Console.WriteLine(list1 + "\n"); //SortedPosList list3 = list1.Clone(); //Console.WriteLine("1 listan: " + list1); //Console.WriteLine("kopierade listan: " + list3); //list2.Add(new Position(3, 7)); //list2.Add(new Position(1, 2)); //list2.Add(new Position(3, 6)); //list2.Add(new Position(2, 3)); //Console.WriteLine((list2 + list1) + "\n"); //SortedPosList circleList = new SortedPosList(); //circleList.Add(new Position(1, 1)); //circleList.Add(new Position(2, 2)); //circleList.Add(new Position(3, 3)); //Console.WriteLine(circleList.CircleContent(new Position(5, 5), 4) + "\n"); //Console.WriteLine(list1[1]); //Console.WriteLine(list1[33]); SortedPosList A = new SortedPosList(); SortedPosList B = new SortedPosList(); A.Add(new Position(3, 7)); A.Add(new Position(1, 4)); A.Add(new Position(2, 6)); A.Add(new Position(2, 3)); B.Add(new Position(3, 7)); B.Add(new Position(1, 2)); B.Add(new Position(3, 6)); B.Add(new Position(2, 3)); Console.WriteLine((A * B) + "\n"); Console.WriteLine((B * A) + "\n"); }
public SortedPosList CircleContent(Position centerPos, double radius) { SortedPosList newCircleList = Clone(); foreach (var pos in positionList) { if (Math.Pow(pos.xPos - centerPos.xPos, 2) + Math.Pow(pos.yPos - centerPos.yPos, 2) > Math.Pow(radius, 2)) { newCircleList.Remove(pos); } } return(newCircleList); }
public SortedPosList CircleContent(Position centerPos, double radius) { SortedPosList circleList = new SortedPosList(); foreach (Position p in PositionsList) { if ((Math.Pow(p.X - centerPos.X, 2) + (Math.Pow(p.Y - centerPos.Y, 2))) < Math.Pow(radius, 2)) { circleList.Add(p.Clone()); } } return(circleList); }