main
Raw Download raw file
 1// Copyright (c) 2015, Emir Pasic. All rights reserved.
 2// Use of this source code is governed by a BSD-style
 3// license that can be found in the LICENSE file.
 4
 5package binaryheap
 6
 7import (
 8	"github.com/emirpasic/gods/containers"
 9)
10
11// Assert Serialization implementation
12var _ containers.JSONSerializer = (*Heap)(nil)
13var _ containers.JSONDeserializer = (*Heap)(nil)
14
15// ToJSON outputs the JSON representation of the heap.
16func (heap *Heap) ToJSON() ([]byte, error) {
17	return heap.list.ToJSON()
18}
19
20// FromJSON populates the heap from the input JSON representation.
21func (heap *Heap) FromJSON(data []byte) error {
22	return heap.list.FromJSON(data)
23}
24
25// UnmarshalJSON @implements json.Unmarshaler
26func (heap *Heap) UnmarshalJSON(bytes []byte) error {
27	return heap.FromJSON(bytes)
28}
29
30// MarshalJSON @implements json.Marshaler
31func (heap *Heap) MarshalJSON() ([]byte, error) {
32	return heap.ToJSON()
33}