CNES / ccsdsmo-malgo

CCSDS MO MAL Go API
https://cnes.github.io/ccsdsmo-malgo
MIT License
10 stars 1 forks source link

Add a function to retrieve an element in a list #9

Closed etiennelndr closed 6 years ago

etiennelndr commented 6 years ago

This pull request adds a new function in the interface ElementList. This function allows to retrieve an element in a list. Here is the new interface:

type ElementList interface {
    Composite
    Size() int
    GetElementAt(i int) Element
}

It required to implement this function for each element that extends ElementList. Here is an example for the type DurationList:

func (list *DurationList) GetElementAt(i int) Element {
    if list != nil {
        if i <= list.Size() {
            return (*list)[i]
        }
        return nil
    }
    return nil
}