Documentation
¶
Overview ¶
things that hold balls
For example, the clock's ball queue is a queue. The clock's time rails are Rails, and both are BallHolders.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BallHolder ¶
type BallHolder struct {
// contains filtered or unexported fields
}
A BallHolder is a thing that holds Balls
func NewBallHolder ¶
func NewBallHolder(capacity uint8, nBalls uint8) BallHolder
Create a new BallHolder
func (BallHolder) IsFull ¶
func (bh BallHolder) IsFull() bool
type Queue ¶
type Queue struct { BallHolder // contains filtered or unexported fields }
The clock's queue
Queue uses a ring buffer to store the balls; instead of the balls moving within the Queue, the ring buffer is updated to point to the appropriate ball.
Because balls are only ever appended, nBalls is used to determine which of the balls are valid, and the rest of the queue is considered empty.
func (*Queue) DoCycleCheck ¶
Return true if the balls are in their original position in the queue
type Rail ¶
type Rail struct { BallHolder Balls []ball.Ball }
The clock's time rails
A Rail holds Balls, but can spill them (down to another ball holder)
Rail uses an array to store the balls.
Unlike a Queue, balls are never "popped" one at a time; instead, when the rail is full, all balls are spilled in reverse order.
Because balls are only ever appended, nBalls is used to determine where to put the balls in the array, and to determine which of the balls are valid, while the rest of the array is considered empty.