Documentation
¶
Index ¶
- type SafeNumber
- func (sn *SafeNumber) Decrement()
- func (sn *SafeNumber) GetAndOperateValue(operation func(int) int) int
- func (sn *SafeNumber) GetValue() int
- func (sn *SafeNumber) GetValueAndDecrement() int
- func (sn *SafeNumber) GetValueAndIncrement() int
- func (sn *SafeNumber) Increment()
- func (sn *SafeNumber) OperateValue(operation func(int) int)
- func (sn *SafeNumber) ResetValue()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SafeNumber ¶
type SafeNumber struct {
// contains filtered or unexported fields
}
SafeNumber is a concurrent-safe number
func NewSafeNumber ¶
func NewSafeNumber(initialValue int) *SafeNumber
NewSafeNumber creates a new SafeNumber
func (*SafeNumber) Decrement ¶
func (sn *SafeNumber) Decrement()
Decrement decrements the number by 1
func (*SafeNumber) GetAndOperateValue ¶
func (sn *SafeNumber) GetAndOperateValue(operation func(int) int) int
GetAndOperateValue performs an operation on the value of the number and returns the result
func (*SafeNumber) GetValue ¶
func (sn *SafeNumber) GetValue() int
GetValue returns the current value of the number
func (*SafeNumber) GetValueAndDecrement ¶
func (sn *SafeNumber) GetValueAndDecrement() int
GetValueAndDecrement returns the current value of the number and decrements it by 1
func (*SafeNumber) GetValueAndIncrement ¶
func (sn *SafeNumber) GetValueAndIncrement() int
GetValueAndIncrement returns the current value of the number and increments it by 1
func (*SafeNumber) Increment ¶
func (sn *SafeNumber) Increment()
Increment increments the number by 1
func (*SafeNumber) OperateValue ¶
func (sn *SafeNumber) OperateValue(operation func(int) int)
OperateValue performs an operation on the value of the number
func (*SafeNumber) ResetValue ¶
func (sn *SafeNumber) ResetValue()
ResetValue resets the value of the number to the initial value
Click to show internal directories.
Click to hide internal directories.