/
dev-npgsql
/
npgsql
Обзор
Документация
Войти
/
dev-npgsql
/
npgsql
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
test-logs
src/Npgsql/Replication/PgOutput/ReadonlyArrayBuffer.cs
57 строк
1 KB
Nino Floris
Remove obsolete UTF-8 BOMs (#6542)
13 апр 2026, 17:13
Не верифицирован
13 апр 2026, 17:13
5225216
Код
Авторство
О чём код?
using System; using System.Collections; using System.Collections.Generic; namespace Npgsql.Replication.PgOutput; sealed class ReadOnlyArrayBuffer<T> : IReadOnlyList<T> { public static readonly ReadOnlyArrayBuffer<T> Empty = new(); T[] _items; int _size; public ReadOnlyArrayBuffer() => _items = []; ReadOnlyArrayBuffer(T[] items) { _items = items; _size = items.Length; } public IEnumerator<T> GetEnumerator() { for (var i = 0; i < _size; i++) { yield return _items[i]; } } IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); public int Count { get => _size; internal set { if (_items.Length < value) _items = new T[value]; _size = value; } } public T this[int index] { get => index < _size ? _items[index] : throw new IndexOutOfRangeException(); internal set => _items[index] = value; } public ReadOnlyArrayBuffer<T> Clone() { var newItems = new T[_size]; if (_size > 0) Array.Copy(_items, newItems, _size); return new(newItems); } }