Skip to content
Snippets Groups Projects
Commit b35a60fb authored by David Sehnal's avatar David Sehnal
Browse files

Int collection type tweaks

parent 4fa48983
No related branches found
No related tags found
No related merge requests found
......@@ -8,6 +8,7 @@ import * as Base from './impl/ordered-set'
import Interval from './interval'
import SortedArray from './sorted-array';
/** test */
namespace OrderedSet {
export const Empty: OrderedSet = Base.Empty as any;
export const ofSingleton: <T extends number = number>(value: T) => OrderedSet<T> = Base.ofSingleton as any;
......@@ -50,7 +51,8 @@ namespace OrderedSet {
}
}
type OrderedSet<T extends number = number> = Interval<T> | SortedArray<T>
//{ '@type': 'int-interval' | 'int-sorted-array' }
/** Represents bla */
type OrderedSet<T extends number = number> = SortedArray<T> | Interval<T>
export default OrderedSet
\ No newline at end of file
......@@ -36,7 +36,7 @@ namespace Selection {
}
export function toLoci(sel: Selection): Element.Loci {
const loci: { unit: Unit, indices: Element.Indices }[] = [];
const loci: { unit: Unit, indices: OrderedSet<Element.Index> }[] = [];
const { unitMap } = sel.source;
for (const unit of unionStructure(sel).units) {
......
......@@ -15,7 +15,6 @@ namespace Element {
/** Index into Unit.elements */
export type Index = { readonly '@type': 'element-index' } & number
export type Indices = OrderedSet<Index>
/** All the information required to access element properties */
export interface Location<U = Unit> {
......@@ -48,11 +47,11 @@ namespace Element {
* Indices into the unit.elements array.
* Can use OrderedSet.forEach to iterate (or OrderedSet.size + OrderedSet.getAt)
*/
indices: Indices
indices: OrderedSet<Index>
}>
}
export function Loci(elements: ArrayLike<{ unit: Unit, indices: Indices }>): Loci {
export function Loci(elements: ArrayLike<{ unit: Unit, indices: OrderedSet<Index> }>): Loci {
return { kind: 'element-loci', elements: elements as Loci['elements'] };
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment