本文整理匯總了TypeScript中vs/editor/common/core/range.Range.compareRangesUsingStarts方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Range.compareRangesUsingStarts方法的具體用法?TypeScript Range.compareRangesUsingStarts怎麽用?TypeScript Range.compareRangesUsingStarts使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類vs/editor/common/core/range.Range
的用法示例。
在下文中一共展示了Range.compareRangesUsingStarts方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1:
return symbols.sort((a, b) => {
// sort by range and provider rank
let ret = Range.compareRangesUsingStarts(a.symbol.range, b.symbol.range);
if (ret === 0) {
ret = provider.indexOf(a.provider) - provider.indexOf(b.provider);
}
return ret;
});
示例2:
decorations = decorations.sort((a, b) => {
let aClassName = a.options.className;
let bClassName = b.options.className;
if (aClassName < bClassName) {
return -1;
}
if (aClassName > bClassName) {
return 1;
}
return Range.compareRangesUsingStarts(a.range, b.range);
});
示例3:
decorations = decorations.sort((a, b) => {
if (a.options.zIndex! < b.options.zIndex!) {
return -1;
}
if (a.options.zIndex! > b.options.zIndex!) {
return 1;
}
const aClassName = a.options.className!;
const bClassName = b.options.className!;
if (aClassName < bClassName) {
return -1;
}
if (aClassName > bClassName) {
return 1;
}
return Range.compareRangesUsingStarts(a.range, b.range);
});
示例4: union
function union(oldLinks: Link[], newLinks: Link[]): Link[] {
// reunite oldLinks with newLinks and remove duplicates
var result: Link[] = [],
oldIndex: number,
oldLen: number,
newIndex: number,
newLen: number,
oldLink: Link,
newLink: Link,
comparisonResult: number;
for (oldIndex = 0, newIndex = 0, oldLen = oldLinks.length, newLen = newLinks.length; oldIndex < oldLen && newIndex < newLen;) {
oldLink = oldLinks[oldIndex];
newLink = newLinks[newIndex];
if (Range.areIntersectingOrTouching(oldLink.range, newLink.range)) {
// Remove the oldLink
oldIndex++;
continue;
}
comparisonResult = Range.compareRangesUsingStarts(oldLink.range, newLink.range);
if (comparisonResult < 0) {
// oldLink is before
result.push(oldLink);
oldIndex++;
} else {
// newLink is before
result.push(newLink);
newIndex++;
}
}
for (; oldIndex < oldLen; oldIndex++) {
result.push(oldLinks[oldIndex]);
}
for (; newIndex < newLen; newIndex++) {
result.push(newLinks[newIndex]);
}
return result;
}
示例5: compareEntriesUsingStart
function compareEntriesUsingStart(a: DocumentSymbol, b: DocumentSymbol): number {
return Range.compareRangesUsingStarts(a.range, b.range);
}
示例6:
newDecorations.sort((a, b) => Range.compareRangesUsingStarts(a.range, b.range));
示例7: _deltaDecorationsImpl
private _deltaDecorationsImpl(eventBuilder:DeferredEventsBuilder, ownerId:number, oldDecorationsIds:string[], newDecorations: ModelDeltaDecoration[]): string[] {
if (oldDecorationsIds.length === 0) {
// Nothing to remove
return this._addDecorationsImpl(eventBuilder, ownerId, newDecorations);
}
if (newDecorations.length === 0) {
// Nothing to add
this._removeDecorationsImpl(eventBuilder, oldDecorationsIds);
return [];
}
let oldDecorations = this._resolveOldDecorations(oldDecorationsIds);
oldDecorations.sort((a, b) => Range.compareRangesUsingStarts(a.range, b.range));
newDecorations.sort((a, b) => Range.compareRangesUsingStarts(a.range, b.range));
let result:string[] = [],
oldDecorationsIndex = 0,
oldDecorationsLength = oldDecorations.length,
newDecorationsIndex = 0,
newDecorationsLength = newDecorations.length,
decorationsToAdd: ModelDeltaDecoration[] = [],
decorationsToRemove: string[] = [];
while (oldDecorationsIndex < oldDecorationsLength && newDecorationsIndex < newDecorationsLength) {
let oldDecoration = oldDecorations[oldDecorationsIndex];
let newDecoration = newDecorations[newDecorationsIndex];
let comparison = Range.compareRangesUsingStarts(oldDecoration.range, newDecoration.range);
if (comparison < 0) {
// `oldDecoration` is before `newDecoration` => remove `oldDecoration`
decorationsToRemove.push(oldDecoration.id);
oldDecorationsIndex++;
continue;
}
if (comparison > 0) {
// `newDecoration` is before `oldDecoration` => add `newDecoration`
decorationsToAdd.push(newDecoration);
newDecorationsIndex++;
continue;
}
// The ranges of `oldDecoration` and `newDecoration` are equal
if (!oldDecoration.options.equals(newDecoration.options)) {
// The options do not match => remove `oldDecoration`
decorationsToRemove.push(oldDecoration.id);
oldDecorationsIndex++;
continue;
}
// Bingo! We can reuse `oldDecoration` for `newDecoration`
result[newDecoration.index] = oldDecoration.id;
oldDecorationsIndex++;
newDecorationsIndex++;
}
while (oldDecorationsIndex < oldDecorationsLength) {
// No more new decorations => remove decoration at `oldDecorationsIndex`
decorationsToRemove.push(oldDecorations[oldDecorationsIndex].id);
oldDecorationsIndex++;
}
while (newDecorationsIndex < newDecorationsLength) {
// No more old decorations => add decoration at `newDecorationsIndex`
decorationsToAdd.push(newDecorations[newDecorationsIndex]);
newDecorationsIndex++;
}
// Remove `decorationsToRemove`
if (decorationsToRemove.length > 0) {
this._removeDecorationsImpl(eventBuilder, decorationsToRemove);
}
// Add `decorationsToAdd`
if (decorationsToAdd.length > 0) {
let newIds = this._addDecorationsImpl(eventBuilder, ownerId, decorationsToAdd);
for (let i = 0, len = decorationsToAdd.length; i < len; i++) {
result[decorationsToAdd[i].index] = newIds[i];
}
}
return result;
}
示例8:
ops.sort((o1, o2) => {
return Range.compareRangesUsingStarts(o1.range, o2.range);
});
示例9: compareDecorations
public static compareDecorations(a:EditorCommon.IModelDecoration, b:EditorCommon.IModelDecoration): number {
return Range.compareRangesUsingStarts(a.range, b.range);
}
示例10: compareEntriesUsingStart
function compareEntriesUsingStart(a: SymbolInformation, b: SymbolInformation): number {
return Range.compareRangesUsingStarts(Range.lift(a.location.range), Range.lift(b.location.range));
}