java - 3D Mapping Data Structure in Guava -


I am implementing a genetic algorithm for scheduling a barrier based university exam. To be able to check the obstruction, I need the data structure, in which most of the information is received before evaluation.

I am currently using table structure from guava as follows:

  table & lt ; Integer, integer, arrelist & lt; Students & gt; & Gt; ClashesMatrix = hashbajet Creation ();   

This means that I am a student in general between exams and examinations in 2D matrix. However now I want to take students one step ahead in the middle of the 3 exams in general, so I need a type of 3D matrix . I need this because one of my obstacles is to examine two or three consecutive examinations for students and to make such data more efficient before preventing obstacles.

Is there any special data in guava , which can be used for this purpose? Or is there any way in which I can change the above table to complete three exams?

This is for your degree because I will appreciate your help! Thank you :)

Your purpose is already for the same direction, now you need another dimension is. And you (important!) Information that has been added key always integer value as mentioned in the answer to your previous question, the performance of autoboxing / autounboxing has an effect here But it should be careful not only for "big" data structures (intentionally not to mention what "big" really means).

For a normal, "N-dimensional" indexing, you can consider your key type in particular, something like IntTuple . (In fact, you can use a list as the & lt; integer & gt; key type, but there may be some drawbacks in it). With the proper implementation of such a IntTuple class, with hashcode and equal , you can easily define an arbitrary, n-dimensional data structure Which is used in the form that is convenient and efficient:

  Maps & lt; IntTuple, list & lt; Students & gt; & Gt; Map = new hashmap & lt; IntTuple, list & lt; Students & gt; & Gt; (); & Lt; Students & gt; Students = New Arrestist & lt; Students & gt; (); Map.put (IntTuple.of (1,2,3), students); & Lt; Students & gt; S = map.get (IntTuple.of (1,2,3));   

However, note that you want to create based on exact questions, a different structure may be more appropriate. For example, this structure allows questions like not

"Let me give them to all students where the second element of 'key topl' is assumed 'x'"

If you need this type of query, a different data structure may be more appropriate.


(In my "Snippets directory" I had such a IntTuple class, I would include it here for convenience ...)

  import java.util.Arrays; Class IntTuple {static intTuple (int ... value) {Return new IntTuple (value); } Private Final Entity Data []; Private IntTuple (int ... data) {this.data = data; } Public int getDimensions () {return data.length; } Public int fetus {return data [index]; } @ Override public string to string () {return arrays.toString (data); } @ Override Public Ent Hashod () {Return Erasehoshod (Data); } @ Override Public Boolean Equivalent (if (this == object) {returns true; } If (object == empty) {return false; } If (! (IntTuple's object installation)) {return false; } IntTuple other = (IntTuple) object; Return Arrays.equals (data, other .data); }}    

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -