搜尋套件、儲存庫與 APP 分類

套件詳情v0.2.2

stack

一個用於堆疊資料結構的套件。具有 push、pop、size、length 和 top 功能。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
2萬
喜歡數
38
Pub 分數
160

安裝套件

flutter pub add stack

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

該 stack 套件在 Dart 中提供了一個簡單且高效之堆疊資料結構實作,支援 push、pop、size、length 及 top 等核心運算。專為需要輕量級、可靠堆疊來管理後進先出(LIFO)資料工作流程的開發者設計。此套件與平台無關,可在 Android、iOS、Web、macOS、Windows 及 Linux 上順暢運作。適用於演算法任務、表示式評估或管理函數呼叫內容,可透過 pub.dev 輕鬆整合至 Flutter 與 Dart 專案中。

適用情境

  • 實現撤銷/重做功能
  • 解析表達式和語法驗證
  • 管理函數調用堆疊
  • 處理嵌套結構
  • 回溯算法

主要特色

  • 推送和彈出操作
  • 存取頂層元素
  • 尺寸和長度屬性
  • 跨平台相容性
  • 最小記憶體佔用

適合對象

  • 需要後進先出資料處理的 Dart 開發人員
  • 演算法實作
  • 教育專案
  • 使用後進先出(LIFO)邏輯進行狀態管理
  • 輕量級實用工具需求

使用建議

  • 不適用於FIFO操作
  • 僅限基本棧行為
  • 無內建執行緒安全性
  • 不支援自定比較器
  • 需要手動處理空棧訪問的錯誤

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

dart_stack

A dart package for stack datastructure

pub codecov CircleCI

Usage

Add dev dependency to your pubspec.yaml:

dev_dependencies:
  stack: ^0.0.1

Run pub get to install.

How it works

Import

import 'package:stack/stack.dart';

Example

// Initialize
Stack<String> stack = Stack();
// Push
stack.push('abc');
// See the top
stack.top();
// Pop the top
stack.pop();
// Check for empty
stack.isEmpty;
// Check for non-enpty
stack.isNotEmpty;
// see if the stack has a certain object
stack.contains("abc");
// print the complete stack
stack.print();
// get size of current stack
stack.size() || var s = stack.size()

Exceptions

Trying to use top() or pop() on an empty stack throws IllegalOperationException. use size(), isEmpty, or isNotEmpty to check before using these operations.

Feel free to file feature requests and bug reports at the issue tracker.

所屬分類

原始碼儲存庫

使用此套件的專案