Heap1 golang에서 heap 사용하기 파이썬 같은 언어는 기본으로 내장되어 있는 heapq가 사용하기 상당히 쉽고 편리한데에 비해 go에서 heap을 사용하려면 꽤나 복잡한 작업을 해야합니다. 이번 글에서는 go에서 heap을 어떻게 사용하는지 공식문서예제에 있는 코드로 알아보겠습니다. 공식문서의 예제 링크: golang.org/src/container/heap/example_pq_test.go 1 func Pop(h Interface) interface{} cs go의 container/heap의 Pop 함수입니다. 인자로 Interface type을 받아야 합니다. 1 2 3 4 5 type Interface interface { sort.Interface Push(x interface{}) Pop() interface{} } cs In.. 2021. 4. 3. 이전 1 다음