Heapq in other langage

I have often used the heapq module on my python program. For the next two years, I want to learn the Dart and Go language. It seems essential to me to have the same functionality as heapq in any language. On this exchange, I want to know and share these few lines of magic code from heapq and see the “best” method in these other languages.

Abstract:

This module provides an implementation of the heap queue algorithm, also known as the priority queue algorithm.

LOGO_Python3

Loading module

import heapq
queue = []

Add a new data in a priority queue

heapq.heappush( queue , ( 0 , [-2 , 3] ) )

Get and remove data from a priority queue

key , data = heapq.heappop( queue )
print(f'comparator: {key} data: {list(map(str,data))}')

LOGO_Dart

Loading module

...

LOGO_Go

Loading module

...

LOGO_C

Loading module

...

addendum: I also asked the question on the community stack but obviously they will not answer because it does not require an answer.

Hello.
Like in any community place, nobody have to answer you. If someone does, it’s voluntarily, on his time, to help you. So if you asked your question like you did here, with no “hello”, no “please”, just a form to fill, I’m no really surprised that nobody answered you.
I don’t know why the heap queue is so essential, when there’s plenty of various containers adapted to every situation, but if I can give you an advice, learning new languages don’t necessarily mean learn how to transpose your python code in those languages, perhaps there is more to learn…
Anyway, if you really want a priority queue in those languages, you already have the keywords to rudely ask Google to answer to your question…
Have a nice day.

Thanks,
Have a nice day.

Well the first results on Google for “heap golang” and “heap dart” are exactly what you need:

https://golang.org/pkg/container/heap/

https://api.flutter.dev/flutter/package-collection_collection/HeapPriorityQueue-class.html

For C I think the spirit is more “if you want anything, do it yourself”.

Thanks,

This is exactly what I need. I understand very well the spirit of C, it is my everyday language.

I have also find the wiki: Heap

Have a nice day.