This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Java tree data-structure?
Is there any Java data structure implementation similar to tree and graph?
Not in the java.util Collections API.
You can use the DefaultTreeModel from Swing for trees.
Jung is a graph framework.
As I answered for a similar question, the Java API contains no general API for trees/graphs, since there is no unique set of features needed in every usecase. There are quite some tree/graph-like APIs for special cases, though.
And in principle it is easy to make your own graph - one could even say that every object is in fact a node in a graph, with the values of its reference type fields being the (outgoing) neighbors.
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
Anyone know what the opposite of a Plain Old Java Object is?
I'm talking about your typical terrible java class. Very complicated, tightly coupled, non-modular quagmire of ridiculousness?
Is there a term for a such a class?
Not sure you understand what is meant by POJO, from wiki-pedia a POJO object is simple an object that doesn't:
Extend a prespecified class, implement a prespecified interface or use annotations.
Basically this means an object that isn't part of a broader framework. Most badly designed, tightly coupled java objects are still POJO.
There is no such thing such the "opposite" of the POJO.
POJO is a simple java object (as you correctly say) and is used to separate them from objects which server special causes. I mention some example object categories which are not POJOs:
EJB
java bean
DTO
COM objects
CORBA objects
Hope I helped!
I know "Big Ball of Mud" is a term applied to software architectures that have the characteristics you describe, so maybe you could apply this term to classes as well.
The term POJO is a bit overused. You need to define it clearly so that you can come up with an opposite in your line of thinking. Following could give you an idea.
"POJO describes Java objects or classes that can function on any java context."
Following this description you can probably consider it to be the opposite of Enterprise Java Beans in a Java EE context.
Have a look at Enterprise Java Beans for more information.
This question already has answers here:
Trie data structures - Java [closed]
(3 answers)
Closed 9 years ago.
I need to create a trie in Java for my Boggle game. I have tried searching for this site for help before hand but only got answers for C or Python but nothing on Java.
Anyways to keep it short, I was wondering how one would go about storing a dictionary (so like a text file of words; around 100k words) into a trie. I've read up about the trie and found it hard to visualize code for it.
Specifically I'm looking for steps to follow when programming (so like what methods I should include and what they do).
Any help would be appreciated!
Have you looked at TrieST? I really suggest you do. Otherwise, I suggest reading this article. Maybe also this one.
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Rule of thumb for choosing an implementation of a Java Collection?
I am looking for a 'Summary' list of all the Java collections detailing the pros and cons of each. I am particularly interested in things like
Which provide faster iteration
Which provide faster search
Which provide slower iteration
Which provide faster insertion or removal
I have seen some sites by searching on Google but i am looking for just a summary preferable in table format.
Thanks in advance.
Take a look at the Collections tutorial, particularly the section on implementations, which includes (in subsections) a discussion of performance characteristics for the various predefined classes. The collections framework is so large, I think, that it would be difficult to summarize everything in a single table.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I need a persistent storage in Java for certain (possibly large) data structures, such as:
dense and sparse matrices of integers, doubles, booleans
directed graphs with labeled nodes and edges
binary trees
maps: string->string, string->integer (with fast retrieval of the keys with largest values)
sets of integers or strings
I don't mind if there is a separate storage for each data structure, as long as all the storages have similar, consistent interfaces.
I need to be able to efficiently modify the data structures "remotely", that is, without fetching the entire structure to RAM, modifying it, and storing back. Example operations: put a key-value in a map, remove a node from a tree, modify a node's label in a graph, add a value to a set.
It would be very nice if these storages could be also easily accessed from other programming languages, most notably Python. I'm thinking of a RESTful service in the backend and client APIs in Java and Python.
Motivation: I need to process a large collection of documents and perform various analyses on them. I want to explore various approaches and create fast prototypes (for that reason I need simple, easy-to-use APIs).
I guess I'm not the first person needing such a functionality and I would hate to reinvent the wheel here. Which brings me to the question: which open-source solutions allow easy-to-use persistence of data structures in Java?
Thanks in advance!
Have you thought about using something like MongoDB? It seem perfect for what your looking for and Its picking up a lot of steam. It's a high-performance, schema-free document-oriented database and I love the fact it's based on json! Check it out!
Here is nice Java tutorial.
How about ObjectOutputStream and ObjectInputStream?
It's very hard to wire all that but you can use JPA with bi-directional mappings and lazy-loading.
It would really depend on you usage patterens, i.e., how many reads, how many writes, how often, etc, but I would suggest you just use sql until you prove that it will not work.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
This is very similar to another question (Functional Data Structures in Java) but the answers there are not particularly useful.
I need to use immutable versions of the standard Java collections (e.g. HashMap / TreeMap / ArrayList / LinkedList / HashSet / TreeSet). By "immutable" I mean immutable in the functional sense (e.g. purely functional data structures), where updating operations on the data structure do not change the original data, but instead return a new instance of the same kind of data structure. Also typically new and old instances of the data structure will share immutable data to be efficient in time and space.
From what I can tell my options include:
Functional Java
Scala
Clojure
but I'm not sure whether any of these are particularly appealing to me. I have a few requirements/desirements:
the collections in question should be usable directly in Java (with the appropriate libraries in the classpath). FJ would work for me; I'm not sure if I can use Scala's or Clojure's data structures in Java w/o having to use the compilers/interpreters from those languages and w/o having to write Scala or Clojure code.
Core operations on lists/maps/sets should be possible w/o having to create function objects with confusing syntaxes (FJ looks slightly iffy)
They should be efficient in time and space. I'm looking for a library which ideally has done some performance testing. FJ's TreeMap is based on a red-black tree, not sure how that rates.
Documentation / tutorials should be good enough so someone can get started quickly using the data structures. FJ fails on that front.
Any suggestions?
It seems to me you already know what your options are, you just aren't happy with any of them. Here is my take on the three choices you've provided:
Functional Java - This one seems like the best fit for you. It fits all of your requirements except that you don't like the documentation. From my perspective the documentation looks basic, but serviceable. Their code snippets should get you up and running quickly. The learning curve seems almost non-existent which should help mitigate the lack of documentation. FYI, core Java's TreeMap is based on a Red-Black tree as well.
Scala - This is the choice I would make if I was in your shoes. You seem to not want to learn a new language, but Scala is a very easy transition from Java. You can write very java-like code at first, and slowly adopt more functional idioms. The Java <-> Scala interop is excellent in both directions as well.
Clojure - As much as I love Clojure, its tough to recommend in this particular instance due to the radically different syntax and steep learning curve for a java developer.
Perhaps Google's guava-libraries may be of some use:
https://code.google.com/p/guava-libraries/wiki/ImmutableCollectionsExplained
Scala
You can call the methods of either language from methods in the other one
http://www.scala-lang.org/faq/4
I've spent some time making the Clojure persistent/immutable data-structures work in Java, with sensible constructors and generics as part of Pure4J.
This also includes #ImmutableValue class for ensuring that not only are the collections immutable, but the values you put in them are immutable too.
Hope this helps.