Comments (8)
I think I had somewhere the idea of making serialization and deserialization (marshalling/unmarshalling) of these structures. My idea was to have that done in a binary form at first, but JSON could also be another option due to readability. Let me meditate on this and find some time, last few months have been crazy for me and I hardly found any free time.
What data structures are you using and would you like this feature for? What is the use case for JSON marshalling?
from gods.
I just discovered this library recently and am using the hashset to store identifiers to start. That list is just a []string
but working with the set API is so much easier and faster at call sites and from a performance perspective I'm sure. On the outgoing interface as json, however, I am just marshaling my own struct to handle this for now but was wondering if it was something that could be done in a generic fashion in the data structure itself.
from gods.
In most cases, the marshalling would have to be handled individually for most structures. They would share a common interface, but the logic would be custom for each. I think that would be a cool feature and will try to include it in this lib, once I clean up the other pull requests.
From the performance perspective, there is a penalty in this lib, because it uses interface{}
types everywhere, which gets hit hard type assertion implementation in Go. I am not criticizing this lib, but one should be aware of that fact when using this lib and it's mainly due to the lack of generics (won't go there, I'll let others be opinionated on this) and, thus, having to type assert everywhere. My suggestion is to use native Go's maps with concrete types if the problem you are working on is simple. The HashSet is really a simple implementation that uses Go's native map, where key is the value as to be unique in the set and the value is empty struct{}{}
.
from gods.
@emirpasic will keep that in mind going forward and hope to see this materialize in the future. I'd like to make more use of this library given its simple and intuitive interfaces compared to go's limited type offerings. If performance becomes an issue, will evaluate my options at that time. Thanks.
from gods.
I was about to ask for something like unmarshaling, it'd be very very useful
from gods.
@LucasZanella sure, marshaling (serialization) and unmarshaling (deserialization) will be implemented together
from gods.
@saheljalal @LucasZanella JSON marshalling and unmarshalling has been implemented in #53 for all data structures.
Please make note of the ToJSON
and FromJSON
functions from the examples and let me know if this works out for you.
from gods.
closed by #53
from gods.
Related Issues (20)
- priorityqueue question HOT 1
- What scenarios will this project be imported HOT 4
- Coverity Scan - Explicit null dereferenced HOT 1
- hashbidimaps Values() returns keys HOT 2
- Why not replace "%+v" to json.Marshal in utils.ToString
- Does it make sense to add goroutine / thread safe data structures for all the existing data structures? HOT 1
- arraylist.List should not maintain size HOT 1
- Add a Ordered linked HOT 2
- Hey! I am interested in translating this project into Portuguese, Brazil. Can I contribute? HOT 1
- I would like to know how to delete a node data while treemap loop read. I want to know where is my code wrong? HOT 2
- Add to Go official wiki? HOT 3
- generic upgrade request HOT 3
- RedBlackTree: Iterators become invalid after removing an element. HOT 2
- DS which can give element if present or next greater if not present, elements should be stored in sorted order HOT 2
- LinkedHashMap Sort? HOT 3
- Multiset support
- deque support
- hashset should support NewWith Comparator
- Add method of Set lack info about the insert take place or not
- treeset:The names of each element are not equal, why is second_8 disappearing? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gods.