| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv static int | Returns: intint segments, int int start, int int limit)Helper method to calculate the span of the sub-interval. |
| public static int[] | Returns: int[]int[] array, int int elementCount, int int segments, int int interval, int int start, int int limit)Returns an int[] array of length segments containing the distribution count of the elements in unsorted int[] array with values between min and max (range). |
| public static int | Returns: intint[] array, int int elements, int int target, int int start, int int limit, int int margin)With an unsorted int[] array and with target a positive integer in the range (1,array.length), finds the value in the range (start,limit) of the largest element (rank) where the count of all smaller elements in that range is less than or equals target. |
| ArrayCounter | back to summary |
|---|---|
| public ArrayCounter() | |
| calcInterval | back to summary |
|---|---|
| pack-priv static int calcInterval(int segments, int start, int limit) Helper method to calculate the span of the sub-interval. Simply returns the ceiling of ((limit - start) / segments) and accounts for invalid start and limit combinations.
| |
| countSegments | back to summary |
|---|---|
| public static int[] countSegments(int[] array, int elementCount, int segments, int interval, int start, int limit) Returns an int[] array of length segments containing the distribution count of the elements in unsorted int[] array with values between min and max (range). Values outside the min-max range are ignored A usage example is determining the count of people of each age group in a large int[] array containing the age of each person. Called with (array, 16,0,79), it will return an int[16] with the first element the count of people aged 0-4, the second element the count of those aged 5-9, and so on. People above the age of 79 are excluded. If the range is not a multiple of segments, the last segment will be cover a smaller sub-range than the rest.
| |
| rank | back to summary |
|---|---|
| public static int rank(int[] array, int elements, int target, int start, int limit, int margin) With an unsorted int[] array and with target a positive integer in the range (1,array.length), finds the value in the range (start,limit) of the largest element (rank) where the count of all smaller elements in that range is less than or equals target. Parameter margin indicates the margin of error in target In statistics, this can be used to calculate a median or quartile value. A usage example applied to an array of age values is to determine the maximum age of a given number of people. With the example array given in countSegments, rank(array, c, 6000, 18, 65, 0) will return an age value between 18-64 (inclusive) and the count of all people aged between 18 and the returned value(exclusive) will be less than or equal to 6000.
| |