Ejemplo n.º 1
0
void PackedArray::Sort(ArrayData* ad, int sort_flags, bool ascending) {
  assert(ad->isPacked());
  if (ad->m_size <= 1) {
    return;
  }
  assert(!ad->hasMultipleRefs());
  auto a = ad;
  if (UNLIKELY(strong_iterators_exist())) {
    free_strong_iterators(a);
  }
  SortFlavor flav = preSort(ad);
  a->m_pos = 0;
  auto data_begin = packedData(ad);
  auto data_end = data_begin + a->m_size;
  CALL_SORT(TVAccessor);
}
Ejemplo n.º 2
0
Geometry*
ConvexHull::getConvexHull()
{
	size_t nInputPts=inputPts.size();

	if (nInputPts==0) // Return an empty geometry
		return geomFactory->createEmptyGeometry();

	if (nInputPts==1) // Return a Point 
	{
		// Copy the Coordinate from the ConstVect
		return geomFactory->createPoint(*(inputPts[0]));
	}

	if (nInputPts==2) // Return a LineString
	{
		// Copy all Coordinates from the ConstVect
		CoordinateSequence *cs = toCoordinateSequence(inputPts);
		return geomFactory->createLineString(cs);
	}

	// use heuristic to reduce points, if large
	if (nInputPts > 50 )
	{
		reduce(inputPts);
	}

	// sort points for Graham scan.
	preSort(inputPts);

	// Use Graham scan to find convex hull.
	Coordinate::ConstVect cHS;
	grahamScan(inputPts, cHS);

	return lineOrPolygon(cHS);

}