public ISimpleOrderedBag <IStudent> GetAllStudentsSorted(IComparer <IStudent> comparer) { var students = new SimpleSortedList <IStudent>((x, y) => comparer.Compare(x, y)); students.AddRange(this.Students.Values as ICollection <IStudent>); return(students); }
public ISimpleOrderedBag <Course> GetAllCoursesSorted(IComparer <Course> comparer) { var sortedCourses = new SimpleSortedList <Course>(comparer); sortedCourses.AddAll(this.courses.Values); return(sortedCourses); }
public ISimpleOrderedBag <ICourse> GetAllCoursesSorted(IComparer <ICourse> comparison) { ISimpleOrderedBag <ICourse> sortedCourses = new SimpleSortedList <ICourse>(comparison); sortedCourses.AddAll(this.coursesByName.Values); return(sortedCourses); }
public ISimpleOrderedBag <Student> GetAllStudentsSorted(Comparison <Student> cmp) { ISimpleOrderedBag <Student> sortedStudents = new SimpleSortedList <Student>(cmp); sortedStudents.AddAll(this.students.Values); return(sortedStudents); }
public ISimpleOrderedBag <Course> GetAllCoursesSorted(Comparison <Course> cmp) { ISimpleOrderedBag <Course> sortedCourses = new SimpleSortedList <Course>(cmp); sortedCourses.AddAll(this.courses.Values); return(sortedCourses); }
public ISimpleOrderedBag <ICourse> GetAllCoursesSorted(IComparer <ICourse> cmp) { SimpleSortedList <ICourse> sortedCourses = new SimpleSortedList <ICourse>(cmp); sortedCourses.AddAll(courses.Values); return(sortedCourses); }
public ISimpleOrderedBag <IStudent> GetAllStudentsSorted(IComparer <IStudent> cmp) { SimpleSortedList <IStudent> sortedStudents = new SimpleSortedList <IStudent>(cmp); sortedStudents.AddAll(students.Values); return(sortedStudents); }
public ISimpleOrderedBag <ICourse> GetAllCoursesSorted(IComparer <ICourse> comparer) { var courses = new SimpleSortedList <ICourse>((x, y) => comparer.Compare(x, y)); courses.AddRange(this.Courses.Values as ICollection <ICourse>); return(courses); }
public ISimpleOrderedBag <IStudent> GetAllStudentsSorted(IComparer <IStudent> comparer) { var sortedStudents = new SimpleSortedList <IStudent>(comparer); sortedStudents.AddAll(this.students.Values); return(sortedStudents); }
public void TestJoinWithNull() { var elements = new[] { "Ivan", "Nasko" }; var sut = new SimpleSortedList <string>(); sut.AddAll(elements); Assert.Throws <ArgumentNullException>(() => sut.JoinWith(null)); }
public void TestSortByInsertion_withInt32(int[] input) { SimpleSortedList <int> digits = new SimpleSortedList <int>(); IComparer <int> comparer = Comparer <int> .Create((x, y) => x.CompareTo(y)); digits.SortByInsertion(input, input.Length, comparer); Assert.That(input, Is.EquivalentTo(input.OrderBy(x => x))); }
public void TestRemoveValidElementDecreasesSize() { var elements = new[] { "Rosen", "Georgi", "Balkan" }; var sut = new SimpleSortedList <string>(); sut.AddAll(elements); sut.Remove("Rosen"); Assert.AreEqual(2, sut.Size); }
public void TestAddingMoreThanInitialCapacity() { var collection = new SimpleSortedList <int>(); for (int i = 1; i < 18; i++) { collection.Add(i); } Assert.That(collection.Capacity, Is.Not.EqualTo(16)); Assert.That(collection.Size, Is.EqualTo(17)); }
public void TestSortByInsertion_withEmptyArray() { SimpleSortedList <string> stringData = new SimpleSortedList <string>(); IComparer <string> comparer = Comparer <string> .Create((x, y) => x.CompareTo(y)); string[] input = new string[] { }; string[] result = new string[] { }; stringData.SortByInsertion(input, input.Length, comparer); Assert.That(input, Is.EquivalentTo(result)); }
public void TestSortByInsertion_withString() { SimpleSortedList <string> stringData = new SimpleSortedList <string>(); IComparer <string> comparer = Comparer <string> .Create((x, y) => x.CompareTo(y)); string[] input = new string[] { "BBBB", "aaaaa", "cccc", "Youu", "eeee", "dd" }; string[] result = new string[] { "aaaaa", "BBBB", "cccc", "dd", "eeee", "Youu" }; stringData.SortByInsertion(input, input.Length, comparer); Assert.That(input, Is.EquivalentTo(result)); }
public ISimpleOrderedBag <ICourse> GetAllCoursesSorted(IComparer <ICourse> cmp) { SimpleSortedList <ICourse> sortedCourses = new SimpleSortedList <ICourse>(cmp); if (this.courses == null) { throw new NullReferenceException(ExceptionMessages.DataNotInitializedExceptionMessage); } sortedCourses.AddAll(this.courses.Values); return(sortedCourses); }
public void TestJoinWorksFine() { var joiner = ", "; var elements = new[] { "Ivan", "Nasko" }; var expectedOutput = string.Join(joiner, elements); var sut = new SimpleSortedList <string>(); sut.AddAll(elements); var stringResult = sut.JoinWith(joiner); Assert.AreEqual(expectedOutput, stringResult); }
public ISimpleOrderedBag <IStudent> GetAllStudentsSorted(IComparer <IStudent> cmp) { SimpleSortedList <IStudent> sortedStudents = new SimpleSortedList <IStudent>(cmp); if (this.students == null) { throw new NullReferenceException(ExceptionMessages.DataNotInitializedExceptionMessage); } sortedStudents.AddAll(this.students.Values); return(sortedStudents); }
public void TestSortByInsertion_withNull() { SimpleSortedList <string> digits = new SimpleSortedList <string>(); IComparer <string> comparer = Comparer <string> .Create((x, y) => x.CompareTo(y)); string[] input = null; try { digits.SortByInsertion(input, input.Length, comparer); Assert.Fail(); } catch (NullReferenceException) { Assert.Pass(typeof(NullReferenceException).Name); } }
/* TODO delete private static List<GridPolygonArea> getBlankPoligon(GridInfo gridInfo) { var width = gridInfo.Width; var height = gridInfo.Height; gridInfo.MinX -= width * 0.2; gridInfo.MaxX += width * 0.2; gridInfo.MinY -= height * 0.2; gridInfo.MaxY += height * 0.2; var poligon = new GridPolygonArea {Type = GridPolygonAreaType.outerArea}; var points = new List<GridPoint>(); points.Add(new GridPoint(gridInfo.MinX, gridInfo.MinY)); points.Add(new GridPoint(gridInfo.MinX, gridInfo.MaxY)); points.Add(new GridPoint(gridInfo.MaxX, gridInfo.MaxY)); points.Add(new GridPoint(gridInfo.MaxX, gridInfo.MinY)); poligon.Points = points.ToArray(); return new List<GridPolygonArea> { poligon }; }*/ private static GridPoint[] getNearestPoints(GridPoint regPoint, GridPoint[] irregularPoints, double radius, int sectorsCount, int maxNumOfPointsInSector) { var points = new SimpleSortedList[sectorsCount]; var sectorPointLength = sectorsCount - 1; for (int idx = 0; idx < sectorsCount; ++idx) { points[idx] = new SimpleSortedList(maxNumOfPointsInSector); } for (int idx = 0; idx < irregularPoints.Length; ++idx) { var irregularPoint = irregularPoints[idx]; var distance = irregularPoint.distanceToPoint2D(regPoint); if (distance <= radius) { var angle = 180 + Math.Atan2(irregularPoint.Y - regPoint.Y, irregularPoint.X - regPoint.X) * 180 / Math.PI; if (angle >= 360) { points[sectorPointLength].add(irregularPoint, distance); continue; } if (angle <= 0) { points[0].add(irregularPoint, distance); continue; } var sect = (int)(angle / (360f / sectorsCount)); points[sect].add(irregularPoint, distance); } } var result = new List<GridPoint>(); for (int idx = 0; idx < sectorsCount; ++idx) { result.AddRange(points[idx].toList()); } return result.ToArray(); }
public ISimpleOrderedBag<IStudent> GetAllStudentsSored(IComparer<IStudent> cmp) { SimpleSortedList<IStudent> sortedStudents = new SimpleSortedList<IStudent>(cmp); sortedStudents.AddAll(this.students.Values); return sortedStudents; }
public ISimpleOrderedBag<ICourse> GetAllCoursesSorted(IComparer<ICourse> cmp) { SimpleSortedList<ICourse> so0RtedCourses = new SimpleSortedList<ICourse>(cmp); so0RtedCourses.AddAll(this.courses.Values); return so0RtedCourses; }
public InnerFrontier() { this.allIKnow = new SimpleSortedList(); this.elements = new Queue <Document>(); }