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' ...@@ -8,6 +8,7 @@ import * as Base from './impl/ordered-set'
import Interval from './interval' import Interval from './interval'
import SortedArray from './sorted-array'; import SortedArray from './sorted-array';
/** test */
namespace OrderedSet { namespace OrderedSet {
export const Empty: OrderedSet = Base.Empty as any; export const Empty: OrderedSet = Base.Empty as any;
export const ofSingleton: <T extends number = number>(value: T) => OrderedSet<T> = Base.ofSingleton as any; export const ofSingleton: <T extends number = number>(value: T) => OrderedSet<T> = Base.ofSingleton as any;
...@@ -50,7 +51,8 @@ namespace OrderedSet { ...@@ -50,7 +51,8 @@ namespace OrderedSet {
} }
} }
type OrderedSet<T extends number = number> = Interval<T> | SortedArray<T> /** Represents bla */
//{ '@type': 'int-interval' | 'int-sorted-array' } type OrderedSet<T extends number = number> = SortedArray<T> | Interval<T>
export default OrderedSet export default OrderedSet
\ No newline at end of file
...@@ -36,7 +36,7 @@ namespace Selection { ...@@ -36,7 +36,7 @@ namespace Selection {
} }
export function toLoci(sel: Selection): Element.Loci { 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; const { unitMap } = sel.source;
for (const unit of unionStructure(sel).units) { for (const unit of unionStructure(sel).units) {
......
...@@ -15,7 +15,6 @@ namespace Element { ...@@ -15,7 +15,6 @@ namespace Element {
/** Index into Unit.elements */ /** Index into Unit.elements */
export type Index = { readonly '@type': 'element-index' } & number export type Index = { readonly '@type': 'element-index' } & number
export type Indices = OrderedSet<Index>
/** All the information required to access element properties */ /** All the information required to access element properties */
export interface Location<U = Unit> { export interface Location<U = Unit> {
...@@ -48,11 +47,11 @@ namespace Element { ...@@ -48,11 +47,11 @@ namespace Element {
* Indices into the unit.elements array. * Indices into the unit.elements array.
* Can use OrderedSet.forEach to iterate (or OrderedSet.size + OrderedSet.getAt) * 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'] }; 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