Iterate lexicographic ordering implementation
This commit is contained in:
parent
21fc386317
commit
a4fa2779d4
4 changed files with 180 additions and 61 deletions
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
import {percentageOf, percentageWithin} from "./numbers";
|
||||
import { percentageOf, percentageWithin } from "./numbers";
|
||||
|
||||
/**
|
||||
* Quickly resample an array to have less/more data points. If an input which is larger
|
||||
|
@ -223,6 +223,21 @@ export function arrayMerge<T>(...a: T[][]): T[] {
|
|||
}, new Set<T>()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves a single element from fromIndex to toIndex.
|
||||
* @param list the list from which to construct the new list.
|
||||
* @param fromIndex the index of the element to move.
|
||||
* @param toIndex the index of where to put the element.
|
||||
* @returns A new array with the requested value moved.
|
||||
*/
|
||||
export function reorder<T>(list: T[], fromIndex: number, toIndex: number): T[] {
|
||||
const result = Array.from(list);
|
||||
const [removed] = result.splice(fromIndex, 1);
|
||||
result.splice(toIndex, 0, removed);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper functions to perform LINQ-like queries on arrays.
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue