vala
1.0.0
1.0.0
  • Учебник Vala
  • Основы
    • Элементы языка
      • Типы данных
      • Управляющие конструкции
      • Методы
      • Делегаты
      • Лямбды / Замыкания
      • Пространства имён
      • Структуры
      • Классы
    • ООП
      • Основы
      • Конструктор
      • Деструктор
      • Сигналы
      • Свойства(Properties)
      • Наследование
      • Абстрактные классы
      • Интерфейсы / Миксины
      • Полиморфизм
      • Сокрытие методов
      • Информация о типах времени выполнения(Run-Time Type Information)
      • Динамическое приведение типов(Dynamic Type Casting)
      • Универсальные шаблоны(Generics)
      • Создание объектов в стиле GObject
      • Интеграция с D-Bus
      • Профили(Другие бэкенды помимо GLib)
  • Продвинутые возможности
    • Ассерты и контрактное программирование
    • Обработка ошибок
    • Управление параметрами
    • Методы с поддержкой синтаксиса
    • Многопоточность
    • Главный цикл(The Main Loop)
    • Асинхронные методы
    • Слабые ссылки(Weak References)
    • Список аргументов переменной длины
    • Указатели
    • Классы не наследующие Object
    • Коллекции
      • Введение
      • HashSet<G>
      • ArrayList<G>
      • HashMap<K,V>
      • Lock-free структуры
  • Экспериментальные фичи
    • Введение
    • Строгий не null режим(Rust mode)
    • Литералы регулярных выражений(regexp)
    • Цепочки связанных выражений
  • Использование и создание библиотек
    • Введение
    • Инструменты
    • Генерирование VAPI файла из предыдущего с помощью vapigen.
    • Использование библиотек
    • Создание библиотеки
    • Vala and C
    • Meson
      • Config file
      • Static Library
      • Shared Library
      • Target GLib Version
  • Технические приёмы
    • Unit тестирование
    • Отладка
    • Использование GLib
  • Продвинуты гайд(WIP)
  • Habr
  • Примеры кода
  • Functional Programming
    • Gpseq
    • Compose
  • Examples
    • Basic
    • GTK
      • Базовые GTK программы
      • Flappy Bird(WIP)
      • DnD
    • Websocket
  • Apps
    • Games
  • Meson-Book
    • MesonBook
    • Wrap
    • Crosscompile
    • Object files
    • Library
    • Executable
    • Code Generation
    • Installing
    • Unit Tests
    • Meson 0.54
    • Meson 0.53
  • golang-book
    • Ваша первая программа
    • Типы
    • UPDATE.MD
Powered by GitBook
On this page
  • Когда использовать
  • List Example
  • Content:

Was this helpful?

  1. Продвинутые возможности
  2. Коллекции

ArrayList<G>

PreviousHashSet<G>NextHashMap<K,V>

Last updated 6 years ago

Was this helpful?

Реализация массива изменяемого размера c интерфейсом .

Массив автоматически увеличивается при необходимости.

Когда использовать

List Example

using Gee;

void main () {
    var list = new ArrayList<int> ();
    list.add (1);
    list.add (2);
    list.add (5);
    list.add (4);
    list.insert (2, 3);
    list.remove_at (3);
    foreach (int i in list) {
        stdout.printf ("%d\n", i);
    }
    list[2] = 10;                       // same as list.set (2, 10)
    stdout.printf ("%d\n", list[2]);    // same as list.get (2)
}

Compile and Run

$ valac --pkg gee-0.8 gee-list.vala
$ ./gee-list

You can use any type fitting into the size of a pointer (e.g. int, bool, reference types) directly as generic type argument: <bool>, <int>, <string>, <MyObject>. Other types must be "boxed" by appending a question mark: <float?>, <double?>, <MyStruct?>. The compiler will tell you this if necessary.

Content:

Properties:

Creation methods:

Methods:

Эта реализация хороша для редко изменяемых данных. Поскольку данные хранятся в массиве, эта структура не подходит для сильно изменяемых данных. альтернативная реализация см. .

public <> { get; } The elements' equality testing function.

public override { get; } Specifies whether this collection can change - i.e. wheather , etc. are legal operations.

public override { get; } The number of items in this collection.

public (owned <>? equal_func = null) Constructs a new, empty array list.

public (owned [] items, owned <>? equal_func = null) Constructs a new array list based on provided array.

public override (<> f)

public override ( index) Returns the item at the specified index in this list.

public override void ( index, item) Sets the item at the specified index in this list.

public override ( item) Adds an item to this collection. Must not be called on read-only collections.

public (<> collection)

public override <> () Returns a BidirListIterator that can be used for iteration over this list.

public override void () Removes all items from this collection. Must not be called on read-only collections.

public override ( item) Determines whether this collection contains the specified item.

public override ( item) Returns the index of the first occurence of the specified item in this list.

public override void ( index, item) Inserts an item into this list at the specified position.

public override <> () Returns a that can be used for simple iteration over a collection.

public override <> () Returns a ListIterator that can be used for iteration over this list.

public override ( item) Removes the first occurence of an item from this collection. Must not be called on read-only collections.

public override ( index) Removes the item at the specified index of this list.

public override <>? ( start, stop) Returns a slice of this list.

Полный список коллекций см .

LinkedList
EqualDataFunc
G
equal_func
bool
read_only
add
remove
int
size
ArrayList
EqualDataFunc
G
ArrayList.wrap
G
EqualDataFunc
G
bool
@foreach
ForallFunc
G
G
@get
int
@set
int
G
bool
add
G
bool
add_all
Collection
G
BidirListIterator
G
bidir_list_iterator
clear
bool
contains
G
int
index_of
G
insert
int
G
Iterator
G
iterator
Iterator
ListIterator
G
list_iterator
bool
remove
G
G
remove_at
int
List
G
slice
int
int
здесь
List