> ## Documentation Index
> Fetch the complete documentation index at: https://snowglobe.so/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Generics And Base Classes

## ArbitraryModel

```python theme={null}
class ArbitraryModel(BaseModel)
```

Empty Pydantic model with a config that allows arbitrary types.

## Stack

```python theme={null}
class Stack(List[T])
```

### \_\_init\_\_

```python theme={null}
def __init__(
    *args,
    max_length: Optional[int] = None
)
```

Creates a new Stack with an optional maximum length.

### empty

```python theme={null}
def empty() -> bool
```

Tests if this stack is empty.

### peek

```python theme={null}
def peek() -> Optional[T]
```

Looks at the object at the top (last/most recently added) of this stack without removing it from the stack.

### pop

```python theme={null}
def pop() -> Optional[T]
```

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

### push

```python theme={null}
def push(item: T) -> None
```

Pushes an item onto the top of this stack.

Proxy of List.append

Limits Stack Length to \_max\_length entries

### search

```python theme={null}
def search(x: T) -> Optional[int]
```

Returns the 0-based position of the last item whose value is equal to x on this stack.

We deviate from the typical 1-based position used by Stack classes (i.e. Java) because most python users (and developers in general) are accustomed to 0-based indexing.

### at

```python theme={null}
def at(index: int, default: Optional[T] = None) -> Optional[T]
```

Returns the item located at the index.

If the index does not exist in the stack (Overflow or Underflow), None is returned instead.

### copy

```python theme={null}
def copy() -> "Stack[T]"
```

Returns a copy of the current Stack.

### first

```python theme={null}
@property
def first() -> Optional[T]
```

Returns the first item of the stack without removing it.

Same as Stack.bottom.

### last

```python theme={null}
@property
def last() -> Optional[T]
```

Returns the last item of the stack without removing it.

Same as Stack.top.

### bottom

```python theme={null}
@property
def bottom() -> Optional[T]
```

Returns the item on the bottom of the stack without removing it.

Same as Stack.first.

### top

```python theme={null}
@property
def top() -> Optional[T]
```

Returns the item on the top of the stack without removing it.

Same as Stack.last.

### length

```python theme={null}
@property
def length() -> int
```

Returns the number of items in the Stack.
