From 1748692d2b53c4e41ee894f95df50bb31edcf9ec Mon Sep 17 00:00:00 2001 From: Kai O'Reilly Date: Sun, 3 Sep 2023 21:38:11 -0700 Subject: [PATCH] deleted atomctr, fatomic, and indent --- atomctr/atomctr.go | 49 -------------------------------- fatomic/fatomic.go | 47 ------------------------------- indent/indent.go | 70 ---------------------------------------------- 3 files changed, 166 deletions(-) delete mode 100644 atomctr/atomctr.go delete mode 100644 fatomic/fatomic.go delete mode 100644 indent/indent.go diff --git a/atomctr/atomctr.go b/atomctr/atomctr.go deleted file mode 100644 index d3a7653..0000000 --- a/atomctr/atomctr.go +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) 2018, The GoKi Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package atomctr implements basic atomic int64 counter, used e.g., for -// update counter on Ki Node -package atomctr - -import ( - "sync/atomic" -) - -// Ctr implements basic atomic int64 counter, used e.g., for update counter on Ki Node -type Ctr int64 - -// increment counter -func (a *Ctr) Add(inc int64) int64 { - return atomic.AddInt64((*int64)(a), inc) -} - -// decrement counter -func (a *Ctr) Sub(dec int64) int64 { - return atomic.AddInt64((*int64)(a), -dec) -} - -// inc = ++ -func (a *Ctr) Inc() int64 { - return atomic.AddInt64((*int64)(a), 1) -} - -// dec = -- -func (a *Ctr) Dec() int64 { - return atomic.AddInt64((*int64)(a), -1) -} - -// current value -func (a *Ctr) Value() int64 { - return atomic.LoadInt64((*int64)(a)) -} - -// set current value -func (a *Ctr) Set(val int64) { - atomic.StoreInt64((*int64)(a), val) -} - -// swap new value in and return old value -func (a *Ctr) Swap(val int64) int64 { - return atomic.SwapInt64((*int64)(a), val) -} diff --git a/fatomic/fatomic.go b/fatomic/fatomic.go deleted file mode 100644 index c9a42f3..0000000 --- a/fatomic/fatomic.go +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) 2019, The Emergent Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package fatomic provides floating-point atomic operations -package fatomic - -import ( - "math" - "sync/atomic" - "unsafe" -) - -// from: -// https://stackoverflow.com/questions/27492349/go-atomic-addfloat32 - -// AddFloat32 adds given increment to a float32 value atomically -func AddFloat32(val *float32, inc float32) (nval float32) { - for { - old := *val - nval = old + inc - if atomic.CompareAndSwapUint32( - (*uint32)(unsafe.Pointer(val)), - math.Float32bits(old), - math.Float32bits(nval), - ) { - break - } - } - return -} - -// AddFloat64 adds given increment to a float64 value atomically -func AddFloat64(val *float64, inc float64) (nval float64) { - for { - old := *val - nval = old + inc - if atomic.CompareAndSwapUint64( - (*uint64)(unsafe.Pointer(val)), - math.Float64bits(old), - math.Float64bits(nval), - ) { - break - } - } - return -} diff --git a/indent/indent.go b/indent/indent.go deleted file mode 100644 index 585fa91..0000000 --- a/indent/indent.go +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright (c) 2018, The GoKi Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -/* -Package indent provides trivial indentation generation methods: Tabs, -Spaces, and Indent with a selector. Also bytes versions. -Just for clarity, simplicity. -*/ -package indent - -import ( - "bytes" - "strings" -) - -// Char is the type of indentation character to use -type Char int - -const ( - // Tab uses tab for indentation - Tab Char = iota - - // Space uses spaces for indentation - Space -) - -// Tabs returns a string of n tabs -func Tabs(n int) string { - return strings.Repeat("\t", n) -} - -// TabBytes returns []byte of n tabs -func TabBytes(n int) []byte { - return bytes.Repeat([]byte("\t"), n) -} - -// Spaces returns a string of n*width spaces -func Spaces(n, width int) string { - return strings.Repeat(" ", n*width) -} - -// SpaceBytes returns a []byte of n*width spaces -func SpaceBytes(n, width int) []byte { - return bytes.Repeat([]byte(" "), n*width) -} - -// String returns a string of n tabs or n*width spaces depending on the indent char -func String(ich Char, n, width int) string { - if ich == Tab { - return Tabs(n) - } - return Spaces(n, width) -} - -// Bytes returns []byte of n tabs or n*width spaces depending on the indent char -func Bytes(ich Char, n, width int) []byte { - if ich == Tab { - return TabBytes(n) - } - return SpaceBytes(n, width) -} - -// Len returns the length of the indent string given indent char and indent level -func Len(ich Char, n, width int) int { - if ich == Tab { - return n - } - return n * width -}