/** * Collection Write Interface * @desczh * 可写入集合接口 * @file * @since 0.2.0 */ import { Kind, URIS } from 'fp-ts/HKT'; import { Option } from 'fp-ts/Option'; import { IndexReaderCollection } from './IndexReaderCollection'; import { WriterCollection } from './WriterCollection'; /** * Collection Write Input Interface * @desczh * 可写入集合输入接口 * @since 0.2.0 */ export interface IndexWriteCollectionInput { /** * Delete the element at the specified index, creating a new collection, or returning `None` if the index is out of bounds * @desczh * 删除一个指定位置的元素,返回删除后的集合 * @example * import { deleteAt } from 'fp-ts/Array' * import { some, none } from 'fp-ts/Option' * * assert.deepStrictEqual(deleteAt(0)([1, 2, 3]), some([2, 3])) * assert.deepStrictEqual(deleteAt(1)([]), none) * * @since 2.0.0 */ _deleteAt: (i: number) => (as: Kind) => Kind; /** * Change the element at the specified index, creating a new collection, or returning `None` if the index is out of bounds * @desczh * 修改一个指定位置的元素,返回修改后的集合 * @example * import { setAt } from 'fp-ts/Array' * import { some, none } from 'fp-ts/Option' * * assert.deepStrictEqual(setAt(1, 1)([1, 2, 3]), some([1, 1, 3])) * assert.deepStrictEqual(setAt(1, 1)([]), none) * * @since 2.0.0 */ _setAt: (i: number, a: A) => (as: Kind) => Kind; /** * Insert an element at the specified index, creating a new list, or returning `None` if the index is out of bounds * @desczh * 插入一个指定位置的元素,返回插入后的集合 * @example * import { insertAt } from 'fp-ts/List' * import { some } from 'fp-ts/Option' * * assert.deepStrictEqual(insertAt(2, 5)([1, 2, 3, 4]), some([1, 2, 5, 3, 4])) * * @since 0.5.0 */ _insertAt(i: number, a: A): (as: Kind) => Kind; } export interface IndexWriterCollection extends IndexWriteCollectionInput, WriterCollection, IndexReaderCollection { /** * Delete the element at the specified index, creating a new collection, or returning `None` if the index is out of bounds * @desczh * 删除一个指定位置的元素,返回删除后的集合 * @example * import { deleteAt } from 'fp-ts/Array' * import { some, none } from 'fp-ts/Option' * * assert.deepStrictEqual(deleteAt(0)([1, 2, 3]), some([2, 3])) * assert.deepStrictEqual(deleteAt(1)([]), none) * * @since 2.0.0 */ deleteAt: (i: number) => (as: Kind) => Option>; /** * Change the element at the specified index, creating a new collection, or returning `None` if the index is out of bounds * @desczh * 修改一个指定位置的元素,返回修改后的集合 * @example * import { setAt } from 'fp-ts/Array' * import { some, none } from 'fp-ts/Option' * * assert.deepStrictEqual(setAt(1, 1)([1, 2, 3]), some([1, 1, 3])) * assert.deepStrictEqual(setAt(1, 1)([]), none) * * @since 2.0.0 */ setAt: (i: number, a: A) => (as: Kind) => Option>; /** * Insert an element at the specified index, creating a new list, or returning `None` if the index is out of bounds * @desczh * 插入一个指定位置的元素,返回插入后的集合 * @example * import { insertAt } from 'fp-ts/List' * import { some } from 'fp-ts/Option' * * assert.deepStrictEqual(insertAt(2, 5)([1, 2, 3, 4]), some([1, 2, 5, 3, 4])) * * @since 0.5.0 */ insertAt(i: number, a: A): (as: Kind) => Option>; /** * Change the element at the specified index and current item, creating a new collection, or returning `None` if the index is out of bounds * @desczh * 修改一个指定位置的元素,返回修改后的集合 * @example * import { updateAt } from 'fp-ts/Array' * import { some, none } from 'fp-ts/Option' * * assert.deepStrictEqual(updateAt(1, a=>a+1)([1, 2, 3]), some([1, 3, 3])) * * @since 2.0.0 */ updateAt: (i: number, updater: (a: A) => A) => (as: Kind) => Option>; /** * Attaches an element to the front of an `Collection`, creating a new non empty `Collection` * @desczh * 插入一个元素到集合头,返回新集合. * @example * import { cons } from 'fp-ts/Array' * * assert.deepStrictEqual(cons(0)([1, 2, 3]), [0, 1, 2, 3]) * * @since 2.0.0 */ cons: (head: A) => (tail: Kind) => Kind; /** * Append an element to the end of an `Collection`, creating a new `Collection` * @desczh * 插入一个元素到集合尾部,返回新集合. * @example * import { snoc } from 'fp-ts/Array' * * assert.deepStrictEqual(snoc(4)([1, 2, 3]), [1, 2, 3, 4]) * * @since 2.0.0 */ snoc: (end: A) => (init: Kind) => Kind; /** * Append an element to the end of an `Collection`, creating a new `Collection` * @alias snoc * @desczh * 插入一个元素到集合尾部,返回新集合.是snoc的别名. * @example * import { push } from 'fp-ts/Array' * * assert.deepStrictEqual(push(4)([1, 2, 3]), [1, 2, 3, 4]) * * @since 2.0.0 */ push: (end: A) => (init: Kind) => Kind; } export declare function initWriter(option: IndexReaderCollection & IndexWriteCollectionInput): IndexWriterCollection;