Skip to content

io microsphere collection ArrayStack

github-actions[bot] edited this page Mar 21, 2026 · 1 revision

ArrayStack

Type: Class | Module: microsphere-java-core | Package: io.microsphere.collection | Since: 1.0.0

Source: microsphere-java-core/src/main/java/io/microsphere/collection/ArrayStack.java

Overview

The Stack class represents a last-in-first-out (LIFO) stack of objects. It extends class Vector with five operations that allow a vector to be treated as a stack. The usual push and pop operations are provided, as well as a method to peek at the top item on the stack, a method to test for whether the stack is empty, and a method to search the stack for an item and discover how far it is from the top.

The non thread-safe version of Stack.

Declaration

public class ArrayStack<E> extends ArrayList<E>

Author: Mercy

Version Information

  • Introduced in: 1.0.0
  • Current Project Version: 0.1.10-SNAPSHOT

Version Compatibility

This component is tested and compatible with the following Java versions:

Java Version Status
Java 8 ✅ Compatible
Java 11 ✅ Compatible
Java 17 ✅ Compatible
Java 21 ✅ Compatible
Java 25 ✅ Compatible

Usage

Maven Dependency

Add the following dependency to your pom.xml:

<dependency>
    <groupId>io.github.microsphere-projects</groupId>
    <artifactId>microsphere-java-core</artifactId>
    <version>${microsphere-java.version}</version>
</dependency>

Tip: Use the BOM (microsphere-java-dependencies) for consistent version management. See the Getting Started guide.

Import

import io.microsphere.collection.ArrayStack;

API Reference

Public Methods

Method Description
push Creates an empty Stack.
pop Removes the object at the top of this stack and returns that
peek Looks at the object at the top of this stack without removing it
empty Tests if this stack is empty.
search Returns the 1-based position where an object is on this stack.

Method Details

push

public E push(E item)

Creates an empty Stack. / public ArrayStack() { this(0); }

/** Constructs a new, empty stack with the specified initial capacity.

pop

public E pop()

Removes the object at the top of this stack and returns that object as the value of this function.

peek

public E peek()

Looks at the object at the top of this stack without removing it from the stack.

search

public int search(Object o)

Returns the 1-based position where an object is on this stack. If the object o occurs as an item in this stack, this method returns the distance from the top of the stack of the occurrence nearest the top of the stack; the topmost item on the stack is considered to be at distance 1. The equals method is used to compare o to the items in this stack.

See Also

  • ArrayList
  • Stack

This documentation was auto-generated from the source code of microsphere-java.

Home

java-annotations

java-core

jdk-tools

lang-model

annotation-processor

java-test

Clone this wiki locally