Reverse the LineString to be oriented counter-clockwise.
@param lineString
@return
178024
private static LineString getCounterClockWise(final LineString lineString) {
        final Coordinate c0 = lineString.getCoordinateN(0);
        final Coordinate c1 = lineString.getCoordinateN(1);
        final Coordinate c2 = lineString.getCoordinateN(2);
        lineString.apply(new UpdateZCoordinateSequenceFilter(0, 3));
        if (CGAlgorithms.computeOrientation(c0, c1, c2) == CGAlgorithms.COUNTERCLOCKWISE) {
            return lineString;
        } else {
            return (LineString) lineString.reverse();
        }
    }
154640
private static LineString reverse3D(LineString lineString, String order) {
        CoordinateSequence seq = lineString.getCoordinateSequence();
        double startZ = seq.getCoordinate(0).z;
        double endZ = seq.getCoordinate(seq.size() - 1).z;
        if (order.equalsIgnoreCase("desc")) {
            if (!Double.isNaN(startZ) && !Double.isNaN(endZ) && startZ < endZ) {
                CoordinateSequences.reverse(seq);
                return FACTORY.createLineString(seq);
            }
        } else if (order.equalsIgnoreCase("asc")) {
            if (!Double.isNaN(startZ) && !Double.isNaN(endZ) && startZ > endZ) {
                CoordinateSequences.reverse(seq);
                return FACTORY.createLineString(seq);
            }
        }
        else {
            throw new IllegalArgumentException("Supported order values are asc or desc.");
        }
        return lineString;
    }
463139
public CharTrie reverse() {
    CharTrie result = new CharTrieIndex();
    TreeMap<Character, ? extends TrieNode> childrenMap = root().getChildrenMap();
    reverseSubtree(childrenMap, result.root());
    return result.recomputeCursorDetails();
  }
327543
public void reverse() {
	// overridden for performance only.
	double tmp;
	int limit=size/2;
	int j=size-1;

	double[] theElements = elements;
	for (int i=0; i<limit;) { //swap
		tmp=theElements[i];
		theElements[i++]=theElements[j];
		theElements[j--]=tmp;
	}
}
303696
public static <T> Collector<T, ?, List<T>> toListReversed() {
		return Collectors.collectingAndThen(Collectors.toList(), l -> {
			Collections.reverse(l);
			return l;
		});
	}
804542
public static @Nonnull JsonArray toJsonJLineString(@Nonnull double[][] lineString) {
        JsonArray points = array();
        for (double[] values : lineString) {
            JsonArray subArray = array();
            for (double value : values) {
                subArray.add(primitive(value));
            }
            points.add(subArray);
        }

        return points;
    }
1127929
public static LinearRing removeCoordinates(LinearRing g) {
        Coordinate[] coords = CoordinateUtils.removeDuplicatedCoordinates(g.getCoordinates(),false);
        return FACTORY.createLinearRing(coords);
    }
1045813
private static LinearRing checkLineString(Geometry geometry) throws IllegalArgumentException {
        if (geometry instanceof LinearRing) {
            return (LinearRing) geometry;

        } else if (geometry instanceof LineString) {
            LineString lineString = (LineString) geometry;
            if (lineString.isClosed()) {
                return geometry.getFactory().createLinearRing(lineString.getCoordinateSequence());
            } else {
                throw new IllegalArgumentException("The linestring must be closed.");
            }
        } else  {
            throw new IllegalArgumentException("Only support linestring.");
        }
    }
1139450
public static <C extends Comparable> Ordering<Range<C>> reverseOrderingByLowerEndpoint() {
        Ordering<Range<C>> orderingByLowerEndpoint = orderingByLowerEndpoint();
        return orderingByLowerEndpoint.reverse();
    }
636260
private static String reverseString(String source) {
    int i;
    int len = source.length();
    StringBuffer dest = new StringBuffer();

    for (i = (len - 1); i >= 0; i--) {
      dest.append(source.charAt(i));
    }
    return dest.toString();
  }
849159
public static Geometry reverse3DLine(Geometry geometry, String order) {
        if(geometry == null){
            return null;
        }
        if (geometry instanceof LineString) {
            return reverse3D((LineString) geometry, order);
        } else if (geometry instanceof MultiLineString) {
            return reverse3D((MultiLineString) geometry, order);
        }
        return null;
    }
1167304
public static @Nonnull JsonArray lineStringToPolygon(@Nonnull double[][] lineString) {
        JsonArray jsonJLineString = toJsonJLineString(lineString);
        if (lineString[0][0] != lineString[lineString.length - 1][0] || lineString[0][1] != lineString[lineString.length - 1][1]) {
            // add last coordinate to close the polygon
            jsonJLineString.add(array(lineString[0][0], lineString[0][1]));
        }
        JsonArray result = array();
        result.add(jsonJLineString);
        return result;
    }
1045332
public PolylineOptions toPolyline(LineString lineString) {

        PolylineOptions polylineOptions = new PolylineOptions();
        Double z = null;

        // Try to simplify the number of points in the line string
        List<Point> points = simplifyPoints(lineString.getPoints());

        for (Point point : points) {
            LatLng latLng = toLatLng(point);
            polylineOptions.add(latLng);
            if (point.hasZ()) {
                z = (z == null) ? point.getZ() : Math.max(z, point.getZ());
            }
        }

        if (lineString.hasZ() && z != null) {
            polylineOptions.zIndex(z.floatValue());
        }

        return polylineOptions;
    }
597502
function LineString(lineString) {
        crs(lineString);
        bbox(lineString);
        if (!requiredProperty(lineString, 'coordinates', 'array')) {
            positionArray(lineString.coordinates, 'Line', 1);
        }
    }
606499
public static final boolean clockwise(Angle angle1, Angle angle2)
    {
        return clockwise(angle1.value, angle2.value);
    }
578651
public static MutableFst reverse(Fst infst) {
    infst.throwIfInvalid();

    MutableFst fst = ExtendFinal.apply(infst);

    Semiring semiring = fst.getSemiring();

    MutableFst result = new MutableFst(fst.getStateCount(), semiring);
    result.setInputSymbolsAsCopy(fst.getInputSymbols());
    result.setOutputSymbolsAsCopy(fst.getOutputSymbols());
    MutableState[] stateMap = initStateMap(fst, semiring, result);

    for (int i = 0; i < fst.getStateCount(); i++) {
      State oldState = fst.getState(i);
      MutableState newState = stateMap[oldState.getId()];
      for (int j = 0; j < oldState.getArcCount(); j++) {
        Arc oldArc = oldState.getArc(j);
        MutableState newNextState = stateMap[oldArc.getNextState().getId()];
        double newWeight = semiring.reverse(oldArc.getWeight());
        result.addArc(newNextState, oldArc.getIlabel(), oldArc.getOlabel(), newState, newWeight);
      }
    }
    return result;
  }
997554
@SuppressWarnings("WeakerAccess")
    public static void reverse(int[] order, int offset, int length) {
        for (int i = 0; i < length / 2; i++) {
            int t = order[offset + i];
            order[offset + i] = order[offset + length - i - 1];
            order[offset + length - i - 1] = t;
        }
    }