Debian Codegraph @

queues/priorityqueue/serialization.go

raw symbols SCIP
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 priorityqueue
6
7 import (
8 "github.com/emirpasic/gods/v2/containers"
9 )
10
11 // Assert Serialization implementation
12 var _ containers.JSONSerializer = (*Queue[int])(nil)
13 var _ containers.JSONDeserializer = (*Queue[int])(nil)
14
15 // ToJSON outputs the JSON representation of the queue.
16 func (queue *Queue[T]) ToJSON() ([]byte, error) {
17 return queue.heap.ToJSON()
18 }
19
20 // FromJSON populates the queue from the input JSON representation.
21 func (queue *Queue[T]) FromJSON(data []byte) error {
22 return queue.heap.FromJSON(data)
23 }
24
25 // UnmarshalJSON @implements json.Unmarshaler
26 func (queue *Queue[T]) UnmarshalJSON(bytes []byte) error {
27 return queue.FromJSON(bytes)
28 }
29
30 // MarshalJSON @implements json.Marshaler
31 func (queue *Queue[T]) MarshalJSON() ([]byte, error) {
32 return queue.ToJSON()
33 }