gitee.com/quant1x/gox@v1.21.2/util/binaryheap/serialization.go (about)

     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  
     5  package binaryheap
     6  
     7  import (
     8  	"gitee.com/quant1x/gox/util/internal"
     9  )
    10  
    11  func assertSerializationImplementation() {
    12  	var _ internal.JSONSerializer = (*Heap)(nil)
    13  	var _ internal.JSONDeserializer = (*Heap)(nil)
    14  }
    15  
    16  // ToJSON outputs the JSON representation of the heap.
    17  func (heap *Heap) ToJSON() ([]byte, error) {
    18  	return heap.list.ToJSON()
    19  }
    20  
    21  // FromJSON populates the heap from the input JSON representation.
    22  func (heap *Heap) FromJSON(data []byte) error {
    23  	return heap.list.FromJSON(data)
    24  }