Count the number of pivots (i.e. non-null entries) in a given array.

@param pivots
@return
540549
private int countPivots(Type.Field[] pivots) {
		int count = 0;
		for(int i=0;i!=pivots.length;++i) {
			if(pivots[i] != null) {
				count = count + 1;
			}
		}
		return count;
	}
143378
protected long getRowCount(final String pWhereClause, final String[] pWhereClauseArgs) {
        Cursor cursor = null;
        try {
            final SQLiteDatabase db = getDb();
            if (db == null || !db.isOpen()) {
                return -1;
            }
            cursor = db.rawQuery(
                    "select count(*) from " + TABLE
                            + (pWhereClause == null ? "" : " where " + pWhereClause), pWhereClauseArgs);
            if (cursor.moveToFirst()) {
                return cursor.getLong(0);
            }
        } catch (Exception ex) {
            catchException(ex);
        } finally {
            if (cursor != null) {
                cursor.close();
            }
        }
        return -1;
    }
1269503
public static function pivotToTwoDimension(&$array, array $keys = [])
    {
        foreach ($keys as $key) {
            if (is_object($array)) {
                $array2 = clone $array;
            } else {
                $array2 = $array;
            }

            $array = Arr::set($array, $key, $array2);
        }

        return $array;
    }
732047
private static int countElementOccurrence(Object element, Object[] array) {

        int count = 0;
        for ( int i= 0; i < array.length; ++i ) {
            Object arrayElement = array[i];
            if (arrayElement != null && element != null) {
                if (arrayElement.equals(element)) {
                    count ++;
                }
            }
        }    
        return count;

    }
1168109
public static int neighborsNumber(String[] neighbors)
    {
        int sum = 0;
        for (String s : neighbors)
        {
            if (s != null)
            {
                sum++;
            }
        }
        return sum;
    }
174977
public static int count(int[] array, int value) {
        int count = 0;
        for (int i = 0; i < array.length; i++) {
            if (array[i] == value) {
                count++;
            }
        }
        return count;
    }
17034
public Entries<K, V> entries () {
		if (entries1 == null) {
			entries1 = new OrderedMapEntries(this);
			entries2 = new OrderedMapEntries(this);
		}
		if (!entries1.valid) {
			entries1.reset();
			entries1.valid = true;
			entries2.valid = false;
			return entries1;
		}
		entries2.reset();
		entries2.valid = true;
		entries1.valid = false;
		return entries2;
	}
1233939
private static void quickSortReverse(double[] keys, int[] vals, final int start, final int end) {
    final int len = end - start;
    if(len < INSERTION_THRESHOLD) {
      insertionSortReverse(keys, vals, start, end);
      return;
    }
    final int last = end - 1;

    // Choose pivots by looking at five candidates.
    final int seventh = (len >> 3) + (len >> 6) + 1;
    final int m3 = (start + end) >> 1; // middle
    final int m2 = m3 - seventh;
    final int m1 = m2 - seventh;
    final int m4 = m3 + seventh;
    final int m5 = m4 + seventh;

    // Mixture of insertion and merge sort:
    sortReverse5(keys, vals, m1, m2, m3, m4, m5);

    // Move pivot to the front.
    double pivotkey = keys[m3];
    int pivotval = vals[m3];
    keys[m3] = keys[start];
    vals[m3] = vals[start];

    // The interval to pivotize
    int left = start + 1; // Without pivot
    int right = last; // inclusive

    // This is the classic QuickSort loop:
    while(true) {
      // Move duplicates to right partition, i.e. < here, <= below.
      while(left <= right && keys[left] > pivotkey) {
        left++;
      }
      while(left <= right && pivotkey >= keys[right]) {
        right--;
      }
      if(right <= left) {
        break;
      }
      swap(keys, vals, left, right);
      left++;
      right--;
    }
    // right now points to the last element smaller than the pivot.
    // Move pivot back into the appropriate place
    keys[start] = keys[right];
    vals[start] = vals[right];
    keys[right] = pivotkey;
    vals[right] = pivotval;

    // Recursion when more than one element only:
    if(start + 1 < right) {
      quickSortReverse(keys, vals, start, right);
    }
    int rstart = right + 1;
    // Avoid recursing on duplicates of the pivot:
    while(rstart < last && keys[rstart] >= keys[right]) {
      rstart++;
    }
    // Recurse when _more_ than 1 element only
    if(rstart < last) {
      quickSortReverse(keys, vals, rstart, end);
    }
  }
404979
private int trPivot(int ISAd, int first, int last) {
        int middle;
        int t;

        t = last - first;
        middle = first + t / 2;

        if (t <= 512) {
            if (t <= 32) {
                return trMedian3(ISAd, first, middle, last - 1);
            } else {
                t >>= 2;
                return trMedian5(ISAd, first, first + t, middle, last - 1 - t, last - 1);
            }
        }
        t >>= 3;
        first = trMedian3(ISAd, first, first + t, first + (t << 1));
        middle = trMedian3(ISAd, middle - t, middle, middle + t);
        last = trMedian3(ISAd, last - 1 - (t << 1), last - 1 - t, last - 1);
        return trMedian3(ISAd, first, middle, last);
    }
1333138
public static void bubbleSort(int[] arrays) {
        for (int i = 0; i < arrays.length - 1; i++) {
            for (int j = 0; j < arrays.length - 1 - i; j++) {
                if (arrays[j] > arrays[j + 1]) {
                    switchNumber(arrays, j, j + 1);
                }
            }
        }
    }
466935
public static int getFlattenedItemsCount(final Object... items) {

        return stream(items)
            .map(item -> item.getClass().isArray() ? getFlattenedItemsCount((Object[]) item) : 1)
            .reduce(0, Integer::sum);
    }
879569
public static void countRegionPixels(GrayS32 labeled , int totalRegions , int counts[] ) {

		Arrays.fill(counts,0,totalRegions,0);

		for( int y = 0; y < labeled.height; y++ ) {
			int index = labeled.startIndex + y*labeled.stride;
			for( int x = 0; x < labeled.width; x++ ) {
				counts[labeled.data[index++]]++;
			}
		}
	}
472923
function pivotVector(vectors=[]) {
              return vectors.reduce((result, val, index/*, arr*/) => {
                val.forEach((vecVal, i) => {
                  (index === 0)
                    ? (result.push([vecVal, ]))
                    : (result[ i ].push(vecVal));
                });
                return result;
              }, []);
            }
510030
@Nonnull
  public double [] getDoublePivot ()
  {
    final double [] vals = new double [m_nRows];
    for (int i = 0; i < m_nRows; i++)
      vals[i] = m_aPivot[i];
    return vals;
  }
763075
public int getMedianIndex(final List<Integer> data, int pivot)
    {
        int medianIndex = data.size()/2;
        //What if more than one point have the samve value? Keep incrementing until that dosn't happen
        while(medianIndex < data.size()-1 && allVecs.get(data.get(medianIndex)).get(pivot) == allVecs.get(data.get(medianIndex+1)).get(pivot))
            medianIndex++;
        return medianIndex;
    }
839344
public static double[] getBorders(int numberOfBins, List<Double> counts) {
        Collections.sort(counts);
        if (!counts.isEmpty()) {
            List<Integer> borderInds = findBordersNaive(numberOfBins, counts);
            if (borderInds == null) {
                borderInds = findBorderIndsByRepeatedDividing(numberOfBins, counts);
            }
            double[] result = new double[borderInds.size()];
            for (int i = 0; i < result.length; i++) {
                result[i] = counts.get(borderInds.get(i));
            }
            return result;
        } else
            return new double[]{0.0};
    }
1014711
public static void heapSort(int[] arrays) {
        // 将待排序的序列构建成一个大顶堆
        for (int i = arrays.length / ValueConsts.TWO_INT; i >= 0; i--) {
            heapAdjust(arrays, i, arrays.length);
        }
        // 逐步将每个最大值的根节点与末尾元素交换，并且再调整二叉树，使其成为大顶堆
        for (int i = arrays.length - 1; i > 0; i--) {
            // 将堆顶记录和当前未经排序子序列的最后一个记录交换
            switchNumber(arrays, 0, i);
            // 交换之后，需要重新检查堆是否符合大顶堆，不符合则要调整
            heapAdjust(arrays, 0, i);
        }
    }