public void CleanColumns() { TreeSet <CT_Col> trackedCols = new TreeSet <CT_Col>(CTColComparator.BY_MIN_MAX); CT_Cols newCols = new CT_Cols(); CT_Cols[] colsArray = worksheet.GetColsList().ToArray(); int i = 0; for (i = 0; i < colsArray.Length; i++) { CT_Cols cols = colsArray[i]; CT_Col[] colArray = cols.GetColList().ToArray(); foreach (CT_Col col in colArray) { addCleanColIntoCols(newCols, col, trackedCols); } } for (int y = i - 1; y >= 0; y--) { worksheet.RemoveCols(y); } newCols.SetColArray(trackedCols.ToArray(new CT_Col[trackedCols.Count])); worksheet.AddNewCols(); worksheet.SetColsArray(0, newCols); //this.newCols = new CT_Cols(); //CT_Cols aggregateCols = new CT_Cols(); //List<CT_Cols> colsList = worksheet.GetColsList(); //if (colsList == null) //{ // return; //} //foreach (CT_Cols cols in colsList) //{ // foreach (CT_Col col in cols.GetColList()) // { // CloneCol(aggregateCols, col); // } //} //SortColumns(aggregateCols); //CT_Col[] colArray = aggregateCols.GetColList().ToArray(); //SweepCleanColumns(newCols, colArray, null); //int i = colsList.Count; //for (int y = i - 1; y >= 0; y--) //{ // worksheet.RemoveCols(y); //} //worksheet.AddNewCols(); //worksheet.SetColsArray(0, newCols); }
public CT_Cols addCleanColIntoCols(CT_Cols cols, CT_Col newCol) { // Performance issue. If we encapsulated management of min/max in this // class then we could keep trackedCols as state, // making this log(N) rather than Nlog(N). We do this for the initial // read above. TreeSet <CT_Col> trackedCols = new TreeSet <CT_Col>(CTColComparator.BY_MIN_MAX); trackedCols.AddAll(cols.GetColList()); addCleanColIntoCols(cols, newCol, trackedCols); cols.SetColArray(trackedCols.ToArray(new CT_Col[0])); return(cols); }
public void TestAdd() { const int Value = 600; TreeSet <int> set = new TreeSet <int>(); Assert.Empty(set); set.Add(Value); Assert.Single(set); Assert.Equal(Value, set.First()); int[] expected = { Value }; int[] actual = set.ToArray(); Assert.Equal(expected, actual); }
private readonly TreeDictionary <PointFr, C5.LinkedList <EventPoint> > _events; // Posortowana mapa punktów i odpowiadających im zdarzeń public EventQueue(C5.HashSet <LineSegmentFr> segments, SweepLine sweepLine) // Tworzy nową kolejkę zdarzeń przy użyciu zestawu odcinków { if (segments.Count <= 0) { throw new ArgumentException($"Kolekcja {nameof(segments)} nie może być pusta"); } _events = new TreeDictionary <PointFr, C5.LinkedList <EventPoint> >(new PointFrXThenYComparer()); var minY = Fraction.PositiveInfinity; var maxY = Fraction.NegativeInfinity; var minDeltaX = Fraction.PositiveInfinity; var xs = new TreeSet <Fraction>(); foreach (var s in segments) { xs.Add(s.StartPoint.X); xs.Add(s.EndPoint.X); if (s.MinY < minY) { minY = s.MinY; } if (s.MaxY > maxY) { maxY = s.MaxY; } Insert(s.StartPoint, new EventPoint(s.StartPoint, EventPointType.Left, s, sweepLine)); Insert(s.EndPoint, new EventPoint(s.EndPoint, EventPointType.Right, s, sweepLine)); } var xsArray = xs.ToArray(); for (var i = 1; i < xsArray.Length; i++) { var tempDeltaX = xsArray[i] - xsArray[i - 1]; if (tempDeltaX < minDeltaX) { minDeltaX = tempDeltaX; } } var deltaY = maxY - minY; var slope = deltaY / minDeltaX * -1; // * 1000 sweepLine.SweepLineValue = new LineFr(PointFr.Origin, new PointFr(0, 1)); // slope, PointFr.Origin sweepLine.EventQueue = this; // Porzuciłem pomysł dynamicznego zmianu nachylenia miotły, ponieważ wymagało to obliczania dużych wartości przecięć z osiami wykresu dla prostej przy użyciu Ułamków (StackOverflowException) }
public void TestAddMany() { int[] expected = { 600, 601, 602, 603, 700, 701, 702, 703, 800, 801, 802, 803 }; TreeSet <int> set = new TreeSet <int>(branchingFactor: 3); foreach (var item in expected) { set.Add(item); } Assert.Equal(expected.Length, set.Count); int[] actual = set.ToArray(); Assert.Equal(expected, actual); }
public IGeometry Union() { PointLocator locater = new PointLocator(); // use a set to eliminate duplicates, as required for union #if Goletas HashSet<ICoordinate> exteriorCoords = new HashSet<ICoordinate>(); #else TreeSet exteriorCoords = new TreeSet(); #endif foreach (IPoint point in PointExtracter.GetPoints(_pointGeom)) { ICoordinate coord = point.Coordinate; Locations loc = locater.Locate(coord, _otherGeom); if (loc == Locations.Exterior) { exteriorCoords.Add(coord); } } // if no points are in exterior, return the other geom if (exteriorCoords.Count == 0) { return _otherGeom; } // make a puntal geometry of appropriate size IGeometry ptComp = null; ICoordinateSequence coords = _geomFact.CoordinateSequenceFactory.Create(exteriorCoords.ToArray()); ptComp = coords.Count == 1 ? (IGeometry)_geomFact.CreatePoint(coords.GetCoordinate(0)) : _geomFact.CreateMultiPoint(coords); // add point component to the other geometry return GeometryCombiner.Combine(ptComp, _otherGeom); }
public IGeometry Union() { PointLocator locater = new PointLocator(); // use a set to eliminate duplicates, as required for union #if Goletas HashSet <ICoordinate> exteriorCoords = new HashSet <ICoordinate>(); #else TreeSet exteriorCoords = new TreeSet(); #endif foreach (IPoint point in PointExtracter.GetPoints(_pointGeom)) { ICoordinate coord = point.Coordinate; Locations loc = locater.Locate(coord, _otherGeom); if (loc == Locations.Exterior) { exteriorCoords.Add(coord); } } // if no points are in exterior, return the other geom if (exteriorCoords.Count == 0) { return(_otherGeom); } // make a puntal geometry of appropriate size IGeometry ptComp = null; ICoordinateSequence coords = _geomFact.CoordinateSequenceFactory.Create(exteriorCoords.ToArray()); ptComp = coords.Count == 1 ? (IGeometry)_geomFact.CreatePoint(coords.GetCoordinate(0)) : _geomFact.CreateMultiPoint(coords); // add point component to the other geometry return(GeometryCombiner.Combine(ptComp, _otherGeom)); }
private IEnumerable<BrowseFacet> BuildDynamicRanges() { TreeSet<BrowseFacet> facetSet = new TreeSet<BrowseFacet>(new RangeComparator()); int minCount = ospec.MinHitCount; // we would skip first element at index 0 (which means no value) for (int i = 1; i < count.Length; ++i) { if (count[i] >= minCount) { object val = dataCache.valArray.GetRawValue(i); facetSet.Add(new BrowseFacet(val, count[i])); } } if (ospec.MaxCount <= 0) { ospec.MaxCount = 5; } int maxCount = ospec.MaxCount; BrowseFacet[] facets = facetSet.ToArray(); if (facetSet.Count < maxCount) { ConvertFacets(facets); } else { facets = FoldChoices(facets, maxCount); } return facets; }
public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); info.AddValue("version", 2); info.AddValue("dates", dates.ToArray()); }