Finish the design work before starting any coding.
Type: Posts; User: Norm
Finish the design work before starting any coding.
Another idea for a design:
The original employee items are saved in a list.
Each employee record has a list of its own that contains the employees that must follow.
When a processAfter rule comes...
Continued at: https://coderanch.com/t/712871/java/Algorithm-java-complex-ordering#3338162
Is there a solution for that set of rules? I think it is possible to have a set of rules that is invalid.
For a simple example:
2 after 4
4 after 2
This is an algorithm problem, not a java...
Did you look at my suggestion on using the position of the employee record instead of the employee's id number?
Given these ids: 8,3,6,2
8 is at position 0
3 " 1
6 " 2
2 " 3
The rules...
Your original data was misleading because the ids were in order. The ordering of the rules is done based on the employee's position in the list, not the value of the id number.
Sometimes that happens.
Define a class to hold the rules and save objects of the class in a list that can be processed.
It was not a question. It was a step in solving the problem. Once all the processAfter rules have been received, the program will order them so that after they are applied the results will be a...
You didn't really give a when value for the questions.
Let me try another way. Are these assumptions correct:
All the employee information is given before any ordering of the employees is done. ...
Given those two processAfter received in that order, to get the correct order would require
3 to be moved after 4: 4, 3
and then
1 to be moved after 4: 4, 1, 3
Did you see my other questions?
Can more than one be processedAfter the same employee?
For example:
one.processAfterEmployee(four);
three.processAfterEmployee(four);
What would be the order of one and three?
Are all...
A linked list would be ok.
Also an ArrayList has methods that could be used to move elements in the list: remove and add
What does: ID property that can adjust the order mean?
How and when...
To control the order of the Strings returned by the toString methods used by the LinkedList's toString method, you will need to write your own method(s).
The program puts objects in a list in a...