Path: blob/main/extensions/copilot/src/util/vs/base/common/sequence.ts
13405 views
//!!! DO NOT modify, this file was COPIED from 'microsoft/vscode'12/*---------------------------------------------------------------------------------------------3* Copyright (c) Microsoft Corporation. All rights reserved.4* Licensed under the MIT License. See License.txt in the project root for license information.5*--------------------------------------------------------------------------------------------*/67import { Emitter, Event } from './event';89export interface ISplice<T> {10readonly start: number;11readonly deleteCount: number;12readonly toInsert: readonly T[];13}1415export interface ISpliceable<T> {16splice(start: number, deleteCount: number, toInsert: readonly T[]): void;17}1819export interface ISequence<T> {20readonly elements: T[];21readonly onDidSplice: Event<ISplice<T>>;22}2324export class Sequence<T> implements ISequence<T>, ISpliceable<T> {2526readonly elements: T[] = [];2728private readonly _onDidSplice = new Emitter<ISplice<T>>();29readonly onDidSplice: Event<ISplice<T>> = this._onDidSplice.event;3031splice(start: number, deleteCount: number, toInsert: readonly T[] = []): void {32this.elements.splice(start, deleteCount, ...toInsert);33this._onDidSplice.fire({ start, deleteCount, toInsert });34}35}363738