Return the index of the added element

This commit is contained in:
2024-10-20 12:57:24 +02:00
parent 764b143ff8
commit 8ce7d54d00
7 changed files with 65 additions and 59 deletions

View File

@@ -28,9 +28,9 @@ func NewSource() *Source {
return &Source{CommonAttributes: newCommonAttributes()}
}
// AddAuthor adds the Person as an author to the Source.
func (s *Source) AddAuthor(p *Person) {
addToSlice(&s.Authors, p)
// AddAuthor adds the Person as an author to the Source. It returns an int.
func (s *Source) AddAuthor(p *Person) int {
return addToSlice(&s.Authors, p)
}
// DeleteAuthor deletes the Person at index from the Source. It return an error.
@@ -41,9 +41,9 @@ func (s *Source) DeleteAuthor(index int) error {
return nil
}
// AddCategory adds the Category to the Source.
func (s *Source) AddCategory(c *Category) {
addToSlice(&s.Categories, c)
// AddCategory adds the Category to the Source. It returns an int.
func (s *Source) AddCategory(c *Category) int {
return addToSlice(&s.Categories, c)
}
// DeleteCategory deletes the Category at index from the Source. It return an
@@ -55,9 +55,10 @@ func (s *Source) DeleteCategory(index int) error {
return nil
}
// AddContributor adds the Person as a contributor to the Source.
func (s *Source) AddContributor(c *Person) {
addToSlice(&s.Contributors, c)
// AddContributor adds the Person as a contributor to the Source. It returns an
// int.
func (s *Source) AddContributor(c *Person) int {
return addToSlice(&s.Contributors, c)
}
// DeleteContributor deletes the Person at index from the Source. It return an
@@ -69,9 +70,9 @@ func (s *Source) DeleteContributor(index int) error {
return nil
}
// AddLink adds the Link to the Source.
func (s *Source) AddLink(l *Link) {
addToSlice(&s.Links, l)
// AddLink adds the Link to the Source. It returns an int.
func (s *Source) AddLink(l *Link) int {
return addToSlice(&s.Links, l)
}
// DeleteLink deletes the Link at index from the Source. It return an error.
@@ -82,9 +83,9 @@ func (s *Source) DeleteLink(index int) error {
return nil
}
// AddExtension adds the ExtensionElement to the Source.
func (s *Source) AddExtension(e *ExtensionElement) {
addToSlice(&s.Extensions, e)
// AddExtension adds the ExtensionElement to the Source. It returns an int.
func (s *Source) AddExtension(e *ExtensionElement) int {
return addToSlice(&s.Extensions, e)
}
// DeleteExtension deletes the Extension at index from the Source. It return an