Files
hello-algo/ru/codes/dart/chapter_stack_and_queue/queue.dart
Yudong Jin 772183705e Add ru version (#1865)
* Add Russian docs site baseline

* Add Russian localized codebase

* Polish Russian code wording

* Update ru code translation.

* Update code translation and chapter covers.

* Fix pythontutor extraction.

* Add README and landing page.

* placeholder of profiles

* Use figures of English version

* Remove chapter paperbook
2026-03-28 04:24:07 +08:00

38 lines
1.2 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* File: queue.dart
* Created Time: 2023-03-28
* Author: liuyuxin (gvenusleo@gmail.com)
*/
import 'dart:collection';
void main() {
/* Инициализация очереди */
// В Dart двусторонняя очередь Queue обычно рассматривается как обычная очередь
final Queue<int> queue = Queue();
/* Добавление элемента в очередь */
queue.add(1);
queue.add(3);
queue.add(2);
queue.add(5);
queue.add(4);
print("Очередь queue = $queue");
/* Доступ к элементу в начале очереди */
final int peek = queue.first;
print("Первый элемент peek = $peek");
/* Извлечение элемента из очереди */
final int pop = queue.removeFirst();
print("Извлеченный элемент pop = $pop, queue после извлечения = $queue");
/* Получить длину очереди */
final int size = queue.length;
print("Длина очереди size = $size");
/* Проверка, пуста ли очередь */
final bool isEmpty = queue.isEmpty;
print("Пуста ли очередь = $isEmpty");
}