Skip to main content
Module

x/simplestatistics/index.js>uniqueCountSorted

simple statistics for node & browser javascript
Go to Latest
function uniqueCountSorted
import { uniqueCountSorted } from "https://deno.land/x/simplestatistics@v7.7.5/index.js";

For a sorted input, counting the number of unique values is possible in constant time and constant memory. This is a simple implementation of the algorithm.

Values are compared with ===, so objects and non-primitive objects are not handled in any special way.

Examples

uniqueCountSorted([1, 2, 3]); // => 3 uniqueCountSorted([1, 1, 1]); // => 1

Parameters

x

an array of any kind of value