Skip to content

Commit

Permalink
Merge pull request #226 from observerly/feature/metadata/SortByTagInt…
Browse files Browse the repository at this point in the history
…erface

feat: add SortByTagInterface type to metadata module in @observerly/iris
  • Loading branch information
michealroberts authored Oct 17, 2024
2 parents 8baa0db + 52bc738 commit 57e4ae6
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions pkg/ifd/entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ import "encoding/binary"

/*****************************************************************************************************************/

// Length of an IFD entry in bytes.
const IFDLengthInBytes = 12

/*****************************************************************************************************************/

// An IFDEntry is a single entry in an Image File Directory.
// A value of type DataTypeRational is composed of two 32-bit values,
// thus data contains two uints (numerator and denominator) for a single number.
Expand Down Expand Up @@ -44,3 +49,15 @@ func (e IFDEntry) PutData(p []byte) {
}

/*****************************************************************************************************************/

type SortByTagInterface []IFDEntry

/*****************************************************************************************************************/

func (s SortByTagInterface) Len() int { return len(s) }

func (s SortByTagInterface) Less(i, j int) bool { return s[i].Tag < s[j].Tag }

func (s SortByTagInterface) Swap(i, j int) { s[i], s[j] = s[j], s[i] }

/*****************************************************************************************************************/

0 comments on commit 57e4ae6

Please sign in to comment.