Skip to content

A binary heap that uses generics instead of the sort interface

Notifications You must be signed in to change notification settings

cpustejovsky/genericheap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 

Repository files navigation

generic heap

Binary Heaps using Generics

Rationale

I realized heaps using generics would be faster than heaps using the standard library because those heaps use interfaces and reflection.

How to use

To create a heap with this package, you need a backing array of any type and a HeapProperty function.

The HeapProperty function takes two elements of the same type as your backing array and returns a boolean.

Think of it as returning the relationship between parent and child that you want the heap to maintain.

For a min-heap of two ints, the function would look like this:

func(parent, child int) bool {
    return parent < child
}

For a max-heap of two ints, the function would look like this:

func(parent, child int) bool {
    return parent < child
}

About

A binary heap that uses generics instead of the sort interface

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages