Partitions an attribute.

@param adapter1 Data adapter
@param data1 Data set
@param len Length of data
@param depth Splitting depth
@return List of sorted objects
329017
private <A> ArrayList<int[]> buildPartitions(NumberArrayAdapter<?, A> adapter1, A data1, int len, int depth) {
    final int[] idx = new int[len];
    final double[] tmp = new double[len];
    for(int i = 0; i < len; ++i) {
      idx[i] = i;
      tmp[i] = adapter1.getDouble(data1, i);
    }
    // Sort indexes:
    IntegerArrayQuickSort.sort(idx, (x, y) -> Double.compare(tmp[x], tmp[y]));
    Arrays.sort(tmp); // Should yield the same ordering

    ArrayList<int[]> ret = new ArrayList<>(1 << depth);
    divide(idx, tmp, ret, 0, tmp.length, depth);
    return ret;
  }
493827
private void splitAt(long t) {
        if (data.containsKey(t)) return; // already split at this timestamp

        SortedMap<Long, int[]> head = data.headMap(t);

        int v = head.isEmpty() ? 0 : data.get(head.lastKey())[0];
        data.put(t, new int[]{v});
    }
216344
protected <T> List<List<T>> trivialPartition(List<T> objects, int minEntries, int maxEntries) {
    // build partitions
    final int size = objects.size();
    final int numberPartitions = (int) Math.ceil(((double) size) / maxEntries);
    List<List<T>> partitions = new ArrayList<>(numberPartitions);
    int start = 0;
    for(int pnum = 0; pnum < numberPartitions; pnum++) {
      int end = (int) ((pnum + 1.) * size / numberPartitions);
      if(pnum == numberPartitions - 1) {
        end = size;
      }
      assert ((end - start) >= minEntries && (end - start) <= maxEntries);
      partitions.add(objects.subList(start, end));
      start = end;
    }
    return partitions;
  }
357091
private IntIterator getCommonSplitDimensions(N node) {
    Collection<SplitHistory> splitHistories = new ArrayList<>(node.getNumEntries());
    for(int i = 0; i < node.getNumEntries(); i++) {
      SpatialEntry entry = node.getEntry(i);
      if(!(entry instanceof XTreeDirectoryEntry)) {
        throw new RuntimeException("Wrong entry type to derive split dimension from: " + entry.getClass().getName());
      }
      splitHistories.add(((XTreeDirectoryEntry) entry).getSplitHistory());
    }
    return SplitHistory.getCommonDimensions(splitHistories);
  }
1170162
public int partition(int k, int minPts) {
        List<Neuron> data = new ArrayList<>();
        for (Neuron neuron : neurons) {
            neuron.y = OUTLIER;
            if (neuron.n >= minPts) {
                data.add(neuron);
            }
        }
        
        double[][] proximity = new double[data.size()][];
        for (int i = 0; i < data.size(); i++) {
            proximity[i] = new double[i + 1];
            for (int j = 0; j < i; j++) {
                proximity[i][j] = Math.distance(data.get(i).w, data.get(j).w);
            }
        }

        Linkage linkage = new UPGMALinkage(proximity);
        HierarchicalClustering hc = new HierarchicalClustering(linkage);
        int[] y = hc.partition(k);

        for (int i = 0; i < data.size(); i++) {
            data.get(i).y = y[i];
        }
        
        return data.size();
    }
409724
protected static <A> int[] discretize(NumberArrayAdapter<?, A> adapter, A data, final int len, final int bins) {
    double min = adapter.getDouble(data, 0), max = min;
    for(int i = 1; i < len; i++) {
      double v = adapter.getDouble(data, i);
      if(v < min) {
        min = v;
      }
      else if(v > max) {
        max = v;
      }
    }
    final double scale = (max > min) ? bins / (max - min) : 1;
    int[] discData = new int[len];
    for(int i = 0; i < len; i++) {
      int bin = (int) Math.floor((adapter.getDouble(data, i) - min) * scale);
      discData[i] = bin < 0 ? 0 : bin >= bins ? bins - 1 : bin;
    }
    return discData;
  }
1060662
protected DataStream<T> setConnectionType(StreamPartitioner<T> partitioner) {
		return new DataStream<>(this.getExecutionEnvironment(), new PartitionTransformation<>(this.getTransformation(), partitioner));
	}
1353001
function recurse(data, depth, nodes) {
    var childs = children.call(hierarchy, data, depth),
        node = d3_layout_hierarchyInline ? data : {data: data};
    node.depth = depth;
    nodes.push(node);
    if (childs && (n = childs.length)) {
      var i = -1,
          n,
          c = node.children = [],
          v = 0,
          j = depth + 1,
          d;
      while (++i < n) {
        d = recurse(childs[i], j, nodes);
        d.parent = node;
        c.push(d);
        v += d.value;
      }
      if (sort) c.sort(sort);
      if (value) node.value = v;
    } else if (value) {
      node.value = +value.call(hierarchy, data, depth) || 0;
    }
    return node;
  }
282663
public static String[] splitByLength(String str, int len) {
		int partCount = str.length() / len;
		int lastPartCount = str.length() % len;
		int fixPart = 0;
		if (lastPartCount != 0) {
			fixPart = 1;
		}

		final String[] strs = new String[partCount + fixPart];
		for (int i = 0; i < partCount + fixPart; i++) {
			if (i == partCount + fixPart - 1 && lastPartCount != 0) {
				strs[i] = str.substring(i * len, i * len + lastPartCount);
			} else {
				strs[i] = str.substring(i * len, i * len + len);
			}
		}
		return strs;
	}
906835
protected static <A> double[] computeNormalizedRanks(final NumberArrayAdapter<?, A> adapter, final A data, int len) {
    // Sort the objects:
    int[] s1 = sortedIndex(adapter, data, len);
    final double norm = .5 / (len - 1);
    double[] ret = new double[len];
    for(int i = 0; i < len;) {
      final int start = i++;
      final double val = adapter.getDouble(data, s1[start]);
      while(i < len && adapter.getDouble(data, s1[i]) <= val) {
        i++;
      }
      final double score = (start + i - 1) * norm;
      for(int j = start; j < i; j++) {
        ret[s1[j]] = score;
      }
    }
    return ret;
  }
696784
def partition(cls, iterable, pred):
    

    t1, t2 = itertools.tee(iterable)
    return cls(itertools.filterfalse(pred, t1), filter(pred, t2))
585204
private static int partition(final long[] arr, final int lo, final int hi) {
    int i = lo, j = hi + 1; //left and right scan indices
    final long v = arr[lo]; //partitioning item value
    while (true) {
      //Scan right, scan left, check for scan complete, and exchange
      while (arr[ ++i] < v) {
        if (i == hi) {
          break;
        }
      }
      while (v < arr[ --j]) {
        if (j == lo) {
          break;
        }
      }
      if (i >= j) {
        break;
      }
      final long x = arr[i];
      arr[i] = arr[j];
      arr[j] = x;
    }
    //put v=arr[j] into position with a[lo .. j-1] <= a[j] <= a[j+1 .. hi]
    final long x = arr[lo];
    arr[lo] = arr[j];
    arr[j] = x;
    return j;
  }
40707
function Partition( buffer, start, end ) {

  if( !(this instanceof Partition) )
    return new Partition( buffer, start, end )

  if( buffer != null && !Buffer.isBuffer( buffer ) )
    throw new TypeError( 'Argument must be a Buffer' )

  /** @type {Number} Partition status */
  this.status = 0x00
  /** @type {Number} Partition type identifier */
  this.type = 0x00
  /** @type {Number} Sector count */
  this.sectors = 0x00
  /** @type {Number} LBA of first sector */
  this.firstLBA = 0x00
  /** @type {Number} CHS address of first sector */
  this.firstCHS = new CHS()
  /** @type {Number} CHS address of last sector */
  this.lastCHS = new CHS()

  if( buffer != null ) {
    this.buffer = buffer.slice( start, end )
  }

}
230971
def get_depths_and_dimensions(data, depth):
    
    if not isinstance(data, (list, tuple)):
        # Not checking for Iterable instance, because even Dictionaries and strings
        # are considered as iterables, but that's not what we want the condition to be.
        return ()

    yield depth, len(data)

    for item in data:
        # iterating over all 1 dimension less sub-data items
        yield from get_depths_and_dimensions(item, depth + 1)
1035762
private static <T extends Comparable<T>> List<Interval<T>> combine(Partition<T> p1, Partition<T> p2) throws MIDDException {

        Set<EndPoint<T>> boundSet = new HashSet<EndPoint<T>>();

        //collect all bounds and remove duplicated items
        for (Interval<T> interval : p1.getIntervals()) {
            boundSet.add(interval.getLowerBound());
            boundSet.add(interval.getUpperBound());
        }
        for (Interval<T> interval : p2.getIntervals()) {
            boundSet.add(interval.getLowerBound());
            boundSet.add(interval.getUpperBound());
        }

        //sorting the bounds
        List<EndPoint<T>> sortedBounds = new ArrayList<EndPoint<T>>(boundSet);
        Collections.sort(sortedBounds);

        List<Interval<T>> tempPartition = new ArrayList<Interval<T>>();

        // Generate new intervals
        for (int i = 0; i < sortedBounds.size() - 1; i++) {
            EndPoint<T> lowBound = sortedBounds.get(i);
            EndPoint<T> upBound = sortedBounds.get(i + 1);
            tempPartition.add(new Interval<T>(lowBound));
            tempPartition.add(new Interval<T>(lowBound, upBound));
        }
        // add the last end-point
        if (sortedBounds.size() > 0) {
            EndPoint<T> lastBound = sortedBounds.get(sortedBounds.size() - 1);
            tempPartition.add(new Interval<T>(lastBound));
        } else {
            log.warn("empty sortedBound");

        }
        return tempPartition;
    }
617512
@Override
  public Streamlet<R> repartition(int numPartitions,
                           SerializableBiFunction<R, Integer, List<Integer>> partitionFn) {
    checkNotNull(partitionFn, "partitionFn cannot be null");

    RemapStreamlet<R> retval = new RemapStreamlet<>(this, partitionFn);
    retval.setNumPartitions(numPartitions);
    addChild(retval);
    return retval;
  }
295246
def split_all(reference, sep):
    
    parts = partition_all(reference, sep)
    return [p for p in parts if p not in sep]