How to name: binaryheap.Client VS binaryheap.Binary VS binaryheap.Slice VS binaryheap.Tree

I have implemented a binary heap data structure, my code is inside binary_heap.go in a package called binaryheap :blush:

This binaryheap package defines a struct, which has my binary heap implementation. How should I name this struct:

  • Client
  • Binary
  • Heap
  • Slice <- shows that I have implemented it using an underlying slice
  • Tree <- shows that I have implemented it using an underlying tree

Any suggestions ? What is the idiomatic way ?

P.S.: another naming question: how should I name the following function:

func FilterNils(input []MyInterface) []MyInterface

As the name should say, it takes in a slice of elements, and returns another slice containing only the non nil elements.

Did you define an interface that defines the behaviur of a binary heap? What is the name of this interface?

The name of the actual struct that implements this interface could tell the reader how it is implemented. So binaryheap.Slice and binaryheap.Tree look good.

The function could be named DropNils.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.