update api documentation

This commit is contained in:
Eric Coissac
2024-11-16 05:59:41 +01:00
parent 03f4e88a17
commit f5d79d0bc4
13 changed files with 372 additions and 62 deletions

View File

@@ -5,12 +5,12 @@ import "sync"
// InnerString is a struct that holds a map of strings and a read-write lock for concurrent access.
// The index map is used to store key-value pairs of strings.
type InnerString struct {
index map[string]*string
lock sync.RWMutex
index map[string]*string // Map to store string values
lock sync.RWMutex // Read-write lock for concurrent access
}
// NewInnerString creates a new instance of InnerString.
// The lock is set to false.
// It initializes the index map and prepares the lock for use.
func NewInnerString() *InnerString {
return &InnerString{
index: make(map[string]*string),
@@ -18,14 +18,14 @@ func NewInnerString() *InnerString {
}
// Innerize stores the given value in the index map if it is not already present.
// It returns the value associated with the key, which is either the newly stored value
// It returns the pointer to the string associated with the key, which is either the newly stored value
// or the existing value if it was already present in the map.
//
// Parameters:
// - value: The string value to be stored in the index map.
//
// Returns:
// - The string value associated with the key.
// - A pointer to the string value associated with the key.
func (i *InnerString) Innerize(value string) *string {
i.lock.Lock()
defer i.lock.Unlock()
@@ -38,6 +38,7 @@ func (i *InnerString) Innerize(value string) *string {
return s
}
// Slice returns a slice of strings containing all the values stored in the index map.
func (i *InnerString) Slice() []string {
rep := make([]string, len(i.index))
j := 0