Skip to content

Commit

Permalink
[chore] Add annotations to interface methods
Browse files Browse the repository at this point in the history
  • Loading branch information
BioCrossCoder committed May 19, 2024
1 parent 01ee305 commit 021bec7
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
6 changes: 6 additions & 0 deletions collections/queue/priorityqueue.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,17 @@ import (

// PriorityQueue is an interface for a priority queue.
type PriorityQueue interface {
// Enqueue adds an element to the priority queue with the given priority.
Enqueue(element any, priority int) (ok bool)
// Dequeue removes and returns the element with the highest priority from the priority queue.
Dequeue() (element any, ok bool)
// Peek returns the element with the highest priority from the priority queue without removing it.
Peek() (element any, ok bool)
// Empty checks if the priority queue is empty.
Empty() bool
// Full checks if the priority queue is full.
Full() bool
// Size returns the number of elements in the priority queue.
Size() int
}

Expand Down
5 changes: 5 additions & 0 deletions collections/queue/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@ import "github.com/biocrosscoder/flex/collections/linkedlist"

// Queue is an interface for a queue data structure.
type Queue interface {
// Enqueue adds an element to the end of the queue.
Enqueue(element any) (ok bool)
// Dequeue removes and returns the element at the front of the queue.
Dequeue() (element any, ok bool)
// Peek returns the element at the front of the queue without removing it.
Peek() (element any, ok bool)
// Empty checks if the queue is empty.
Empty() bool
// Full checks if the queue is full.
Full() bool
}

Expand Down
5 changes: 5 additions & 0 deletions collections/stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@ import "github.com/biocrosscoder/flex/collections/linkedlist"

// Stack interface represents a stack data structure
type Stack interface {
// Push adds an element to the top of the stack if it's not full
Push(element any) (ok bool)
// Pop removes and returns the top element from the stack if it's not empty
Pop() (element any, ok bool)
// Peek returns the top element of the stack without removing it if the stack is not empty
Peek() (element any, ok bool)
// Empty checks if the stack is empty
Empty() bool
// Full checks if the stack is full based on its capacity
Full() bool
}

Expand Down
3 changes: 3 additions & 0 deletions itertools/iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ package itertools

// Iterator is an interface that defines the behavior of an iterator.
type Iterator interface {
// Next moves the pointer to the next element and returns true if there is a next element or false otherwise.
Next() bool
// Value returns the element pointed by the pointer.
Value() any
// Pour returns a slice of all remaining elements in the iterator.
Pour() any
}

Expand Down

0 comments on commit 021bec7

Please sign in to comment.