Joins the given ranges into the fewest number of ranges.
If no joining can take place, the original array is returned.

@param ranges
@return
769078
public static IPAddressSeqRange[] join(IPAddressSeqRange... ranges) {
		int joinedCount = 0;
		Arrays.sort(ranges, Address.ADDRESS_LOW_VALUE_COMPARATOR);
		for(int i = 0; i < ranges.length; i++) {
			IPAddressSeqRange range = ranges[i];
			if(range == null) {
				continue;
			}
			for(int j = i + 1; j < ranges.length; j++) {
				IPAddressSeqRange range2 = ranges[j];
				if(range2 == null) {
					continue;
				}
				IPAddress upper = range.getUpper();
				IPAddress lower = range2.getLower();
				if(compareLowValues(upper, lower) >= 0
						|| upper.increment(1).equals(lower)) {
					//join them
					ranges[i] = range = range.create(range.getLower(), range2.getUpper());
					ranges[j] = null;
					joinedCount++;
				} else break;
			}
		}
		if(joinedCount == 0) {
			return ranges;
		}
		IPAddressSeqRange joined[] = new IPAddressSeqRange[ranges.length - joinedCount];
		for(int i = 0, j = 0; i < ranges.length; i++) {
			IPAddressSeqRange range = ranges[i];
			if(range == null) {
				continue;
			}
			joined[j++] = range;
			if(j >= joined.length) {
				break;
			}
		}
		return joined;
	}
197917
public static int count(final Iterable<Range<Long>> ranges) {
        int count = 0;
        for (Range<Long> range : ranges) {
            checkClosedOpen(range);
            count++;
        }
        return count;
    }
906777
public static RangeSet merge(RangeSet rs)
    {
        RangeSet result = new RangeSet();
        int from = -1;
        int to = -1;
        for (CharRange r : rs)
        {
            if (from == -1) // first
            {
                from = r.getFrom();
                to = r.getTo();
            }
            else
            {
                if (r.getFrom() == to)
                {
                    to = r.getTo();
                }
                else
                {
                    result.add(from, to);
                    from = r.getFrom();
                    to = r.getTo();
                }
            }
        }
        result.add(from, to);
        return result;
    }
996141
public static <C extends Comparable> RangeTree<C> create(final Iterable<Range<C>> ranges) {
        return new CenteredRangeTree<C>(ranges);
    }
247940
public static String join(final String... expressions) {
        Validate.notEmpty(expressions);
        final char trigger = isDelimited(expressions[0]) ? getTrigger(expressions[0]) : DEFAULT_TRIGGER;
        return join(trigger, expressions);
    }
1324058
public boolean intersects(Iterable<Range<T>> ranges)
    {
        for (Range<T> range2 : ranges)
        {
            if (range2.intersects(this))
                return true;
        }
        return false;
    }
404281
public double[][] updateRanges(Instance instance, double[][] ranges) {
    // updateRangesFirst must have been called on ranges
    for (int j = 0; j < ranges.length; j++) {
      double value = instance.value(j);
      if (!instance.isMissing(j)) {
        if (value < ranges[j][R_MIN]) {
          ranges[j][R_MIN] = value;
          ranges[j][R_WIDTH] = ranges[j][R_MAX] - ranges[j][R_MIN];
        } else {
          if (instance.value(j) > ranges[j][R_MAX]) {
            ranges[j][R_MAX] = value;
            ranges[j][R_WIDTH] = ranges[j][R_MAX] - ranges[j][R_MIN];
          }
        }
      }
    }
    
    return ranges;
  }
655595
public Range[] minus(Range that){
        Range split[] = split(that);
        if(split[0]==null && split[2]==null)
            return new Range[0];
        if(split[0]!=null && split[2]!=null)
            return new Range[]{ split[0], split[2] };

        return new Range[]{ split[0]!=null ? split[0] : split[2] };
    }
962752
protected String join(List<String> values)
    {
        StringBuilder sb = new StringBuilder(100);
        if(values.size() == 0)
            return sb.toString();

        sb.append(values.get(0));

        if(values.size() == 1)
            return sb.toString();

        for (int i = 1; i < values.size(); i++)
        {
            sb.append(",").append(values.get(i));
        }

        return sb.toString();
    }
496150
@Override
  public Collection<Range<T>> rangesContaining(final Range<T> queryRange) {
    final ImmutableSet.Builder<Range<T>> ret = ImmutableSet.builder();
    for (final Range<T> range : ranges) {
      if (range.encloses(queryRange)) {
        ret.add(range);
      }
    }
    return ret.build();
  }
904682
public static function combination(array $ranges)
	{
		$dateTimeRanges = array();

		foreach ($ranges as $range)
		{
			$dateTimeRanges[] = $range->range;
		}

		return self::cast(DateTimeRange::combination($dateTimeRanges));
	}
181588
private String stringJoin(String[] array, int count){
    String joined = "";
    for(int i = 0; i < count; i++)
      joined += array[i];
    return joined;
  }
201406
public Range intersection(final Range range) {
		int c0 = Math.max(this.start, range.start);
		int c1 = Math.min(this.end, range.end);
		return c0 <= c1 ? new Range(c0, c1) : null;
	}
619603
public static <T> List<T> concat(final Collection<? extends T>... lists)
	{
		ArrayList<T> al = new ArrayList<T>();

		for (Collection<? extends T> list : lists)
			if (list != null)
				al.addAll(list);

		return al;
	}
757175
public static boolean parametersInRange( double[] parameters, double[]... ranges ) {
        for( int i = 0; i < ranges.length; i++ ) {
            if (!NumericsUtilities.isBetween(parameters[i], ranges[i])) {
                return false;
            }
        }
        return true;
    }
155765
def make_ranges(cls, lines):
        
        start_line = last_line = lines.pop(0)
        ranges = []
        for line in lines:
            if line == (last_line + 1):
                last_line = line
            else:
                ranges.append((start_line, last_line))
                start_line = line
                last_line = line
        ranges.append((start_line, last_line))
        return ranges
434212
public boolean inRanges(Instance instance, double[][] ranges) {
    boolean isIn = true;
    
    // updateRangesFirst must have been called on ranges
    for (int j = 0; isIn && (j < ranges.length); j++) {
      if (!instance.isMissing(j)) {
        double value = instance.value(j);
        isIn = value <= ranges[j][R_MAX];
        if (isIn) isIn = value >= ranges[j][R_MIN];
      }
    }
    
    return isIn;
  }