Skip to content

Commit 2cece9b

Browse files
committed
Updated README with dynamic growth of stack implementation
1 parent c5f62a2 commit 2cece9b

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

README.md

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Containers-Stack
2-
A High-performance, Array based Stack implementation providing efficient LIFO (Last In, First Out) operations with fixed capacity and proper bounds checking.
2+
A High-performance, Array-based Stack implementation providing efficient LIFO (Last In, First Out) operations with dynamic growth and proper bounds checking.
33

44
![Pharo Version](https://img.shields.io/badge/Pharo-10+-blue)
55
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
@@ -10,10 +10,9 @@ A Stack is a linear data structure that follows the LIFO (Last In, First Out) pr
1010

1111
### Key Benefits
1212
- **O(1) Performance**: Constant time push, pop, and top operations
13-
- **Fixed Memory Usage**: Array-based implementation with bounded capacity
14-
- **Memory Safe**: Automatic cleanup prevents memory leaks
13+
- **Dynamic Growth**: Automatically expands capacity when needed - no size limits
1514
- **Simple API**: Clean, intuitive interface following standard conventions
16-
- **Robust Error Handling**: Proper stack overflow and underflow protection
15+
- **Robust Error Handling**: Proper stack underflow protection
1716

1817
## Loading
1918
The following script installs Containers-Stack in Pharo.
@@ -38,21 +37,19 @@ spec
3837
## Quick Start
3938

4039
```smalltalk
41-
"Create a stack with capacity of 5"
42-
stack := CTStack new: 5.
40+
"Create a stack (grows automatically when needed)"
41+
stack := CTStack new: 2.
42+
stack capacity. "Returns 2"
4343
44-
"Push elements"
45-
stack push: 'first'.
46-
stack push: 'second'.
47-
stack push: 'third'.
48-
49-
"Check top element without removing"
50-
stack top. "Returns 'third'"
44+
"Push elements - grows beyond initial capacity"
45+
stack push: 'first'; push: 'second'; push: 'third'.
46+
stack capacity. "Returns 4 (doubled automatically)"
5147
stack size. "Returns 3"
5248
53-
"Pop elements (LIFO order)"
49+
"LIFO operations"
50+
stack top. "Returns 'third'"
5451
stack pop. "Returns 'third'"
55-
stack pop. "Returns 'second'"
52+
stack pop. "Returns 'second'"
5653
stack pop. "Returns 'first'"
5754
5855
"Stack is now empty"

0 commit comments

Comments
 (0)