Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Page 1 of 2 12 LastLast
Results 1 to 25 of 27

Thread: Ordering items but a bit more complex then just swapping items

  1. #1
    Junior Member
    Join Date
    Jul 2019
    Posts
    14
    Thanks
    0
    Thanked 11 Times in 11 Posts

    Default Ordering items but a bit more complex then just swapping items

    Hi guys, I am needed some help with a snippet to order a list properly. I have actually turned my use case into a simple employee class for the sake of explaining my issue to everyone.

    In the below example, we have four employees, but I want to be able to set a flag on each instance to be able to re-shuffle the order later - I'm not exactly sure how I can get the order to work after the adjustment?

    The complexity is employee 1 should print after employee 3. This is easy to adjust, I can just insert into the linked list and remove the first index/employee 1.

    But the challenge is that employee 3 should then print after employee 4 - again, easy to make this single adjustment to move 3 to run after 4, BUT then we just set 1 to run after 3 above - and I loose this bit of info. It's kinda like I need some way that when an adjust in the order is made, the code is smart enough to move chunks of employees around rather then swap elements.

    Please note that I have kept the initial default order as 1,2,3,4 but the initial default order can be in any order e.g 4,1,3,2 etc - the point of the question is how to adjust the initial default order by flipping values around given the adjustment

    I'm a novice at algorithms and data structures and was wondering if someone could help me in the right direction.

    Thanks,

    Alfa

    	public static void main(String[] args) 
    	{
                    // default order
    		Employee one = new Employee(1);
    		Employee two = new Employee(2);
    		Employee three = new Employee(3);
    		Employee four = new Employee(4);
     
    		// Add to linked list in the order defined above
    		LinkedList<Employee> list = new LinkedList<>();
    		list.add(one);
    		list.add(two);
    		list.add(three);
    		list.add(four);
    		System.out.println(list); // prints [1, 2, 3, 4]
     
    		// set flags to flip the order
    		one.processAfterEmployeeId(3);
    		three.processAfterEmployeeId(4);
     
    		// this should print [2, 4, 3, 1] as 1 should be AFTER 4, and 3 should be AFTER 4
    	}

    public class Employee
    {
    	int employeeId;
    	int proessAfterEmployeeId;
     
    	public Employee(int employeeId)
    	{
    		this.employeeId = employeeId;
    	}	
     
    	public void processAfterEmployeeId(int id)
    	{
    		this.proessAfterEmployeeId = id;
    	}
     
    	@Override
    	public String toString() 
    	{
    		return employeeId + "";
    	}
    }
    Last edited by alfa86; July 12th, 2019 at 08:14 AM.

  2. The Following User Says Thank You to alfa86 For This Useful Post:

    loncillosamm (July 13th, 2019)

  3. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    22,638
    Thanks
    53
    Thanked 2,417 Times in 2,370 Posts

    Default Re: Ordering items but a bit more complex then just swapping items

    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 certain order. What determines that order? Arrival time?
    Then the processAfter methods are called. Should they change the order in the list?
    Normally items in a list are processed in the order they are in.
    Can the same collection of objects be logically at different positions in a list depending on their contents: age, height, ...

    This is confusing:
    one.processAfterEmployeeId(3); //<<< Implies a search for the employee with id=3
    should it be:
    one.processAfterEmployee(three); // gives reference to employee object
    If you don't understand my answer, don't ignore it, ask a question.

  4. The Following User Says Thank You to Norm For This Useful Post:

    loncillosamm (July 13th, 2019)

  5. #3
    Junior Member
    Join Date
    Jul 2019
    Posts
    14
    Thanks
    0
    Thanked 11 Times in 11 Posts

    Default Re: Ordering items but a bit more complex then just swapping items

    The initial order comes from an external source that I have no control over. The order is initially defined by that system. This process is a bespoke way to customly adjust the order of the list.

    The processAfter methods are called after, they should change the order in the list yes.

    There are no other conditions, only that ID property that can adjust the order. There is no concern for height, age etc etc.

    one.processAfterEmployee(three) makes sense to avoid looking up the instance.

    Can you point me to what kind of datastructure can help me, and potentially an example?

  6. The Following User Says Thank You to alfa86 For This Useful Post:

    loncillosamm (July 13th, 2019)

  7. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    22,638
    Thanks
    53
    Thanked 2,417 Times in 2,370 Posts

    Default Re: Ordering items but a bit more complex then just swapping items

    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 would the ID property be used?
    		one.processAfterEmployeeId(3);
    		three.processAfterEmployeeId(4);
     
    		// this should print [2, 4, 3, 1] as 1 should be AFTER 4, and 3 should be AFTER 4
    Should that comment read: 1 should be AFTER 3, and 3 should be AFTER 4
    That implies the that the order of the calls to the processAfter method needs to be ordered.
    For this example: move 3 after 4 then move 1 after 3
    If you don't understand my answer, don't ignore it, ask a question.

  8. The Following User Says Thank You to Norm For This Useful Post:

    loncillosamm (July 13th, 2019)

  9. #5
    Junior Member
    Join Date
    Jul 2019
    Posts
    14
    Thanks
    0
    Thanked 11 Times in 11 Posts

    Default Re: Ordering items but a bit more complex then just swapping items

    Hi Nord - yes you're right about the comments.

    In terms of your comment:

    "That implies the that the order of the calls to the processAfter method needs to be ordered.
    For this example: move 3 after 4 then move 1 after 3"

    This is exactly my point, this is the challenge, how would we define the rule for the order of the call? And I'm thinking we might need some recursive function in here somewhere too? This is the bit I'm stuck on, not sure how to approach this?

  10. The Following User Says Thank You to alfa86 For This Useful Post:

    loncillosamm (July 13th, 2019)

  11. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    22,638
    Thanks
    53
    Thanked 2,417 Times in 2,370 Posts

    Default Re: Ordering items but a bit more complex then just swapping items

    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 the employee objects available before any of the processAfter rules are applied?
    Are all the processAfter rules available before any reordering of the list is done?
    If so maybe the processAfter rules could be sorted by target in inverse order before applying.

    In other words:
    when do you get the list of employees
    when do you get the list of processAfter rules
    when do you reorder the list based on the processAfter rules
    If you don't understand my answer, don't ignore it, ask a question.

  12. The Following User Says Thank You to Norm For This Useful Post:

    loncillosamm (July 13th, 2019)

  13. #7
    Junior Member
    Join Date
    Jul 2019
    Posts
    14
    Thanks
    0
    Thanked 11 Times in 11 Posts

    Default Re: Ordering items but a bit more complex then just swapping items

    Assumption is that if we have the above scenario where two processAfter occur on the same target, then the first call to the target should take precedence

    one.processAfterEmployeeId(four); would result in 2, 3 ,4, 1
    three.processAfterEmployeeId(four); would result in 2, 4, 1, 3 (1 takes priority as it was already requested to be set after 4)

  14. The Following User Says Thank You to alfa86 For This Useful Post:

    loncillosamm (July 13th, 2019)

  15. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    22,638
    Thanks
    53
    Thanked 2,417 Times in 2,370 Posts

    Default Re: Ordering items but a bit more complex then just swapping items

    one.processAfterEmployee(four);
    three.processAfterEmployee(four);
    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?
    Are all the employee objects available before any of the processAfter rules are applied?
    Are all the processAfter rules available before any reordering of the list is done?
    If so maybe the processAfter rules could be sorted by target in inverse order before applying.

    In other words:
    when do you get the list of employees
    when do you get the list of processAfter rules
    when do you reorder the list based on the processAfter rules
    If you don't understand my answer, don't ignore it, ask a question.

  16. The Following User Says Thank You to Norm For This Useful Post:

    loncillosamm (July 13th, 2019)

  17. #9
    Junior Member
    Join Date
    Jul 2019
    Posts
    14
    Thanks
    0
    Thanked 11 Times in 11 Posts

    Default Re: Ordering items but a bit more complex then just swapping items

    Quote Originally Posted by Norm View Post
    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
    Agree that for all processAfter's that have the same target, processing them in "last in first out" order makes sense.

    On your other questions:
    when do you get the list of employees <-- they come from an external system.

    when do you get the list of processAfter rules <-- a user inputs this in an adhoc manner, if the user wants to process employee one after employee four, he will set this flag on employee one in his system (i.e, the user will set a flag on employee one indicating that it should be processed after employee four)

    when do you reorder the list based on the processAfter rules <-- this is the bit I'm trying to figure out, my illustration/question is based on accumlating all of the processAfter's - the challenge is 1) what order to process them in 2) if shuffling items in the order have already been processed by a previous processAfter then we may need a recursive function somewhere? Or do you see this being as straight forward as just being able to execute the processAfter's in a specific order and that's it?

  18. The Following User Says Thank You to alfa86 For This Useful Post:

    loncillosamm (July 13th, 2019)

  19. #10
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    22,638
    Thanks
    53
    Thanked 2,417 Times in 2,370 Posts

    Default Re: Ordering items but a bit more complex then just swapping items

    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. All received employees are placed in a list in the order they are received.
    All of the processAfter rules are given before any ordering is done.
    All employees and all processAfter rules are received before the employee list is reordered.
    There will not be any more employees or processAfter rules received once the ordering of the list is started.
    The processAfter rules are ordered to give the correct result.
    The employee list is ordered according to the processAfter rules.
    Once the list is reordered, the employees in the list are in the order that they are to be processed.
    If you don't understand my answer, don't ignore it, ask a question.

  20. The Following User Says Thank You to Norm For This Useful Post:

    loncillosamm (July 13th, 2019)

  21. #11
    Junior Member
    Join Date
    Jul 2019
    Posts
    14
    Thanks
    0
    Thanked 11 Times in 11 Posts

    Default Re: Ordering items but a bit more complex then just swapping items

    Hey Norm, apologies for the lack of clarity - answers below

    Quote Originally Posted by Norm View Post
    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. All received employees are placed in a list in the order they are received. Yes exactly right
    All of the processAfter rules are given before any ordering is done. Yes - correct
    All employees and all processAfter rules are received before the employee list is reordered. Yes, correct
    There will not be any more employees or processAfter rules received once the ordering of the list is started. Yes, correct, all employees are received, all processAfter rules are stored, now we are ready to apply the reorder..
    The processAfter rules are ordered to give the correct result. Not sure I understood this question, the processAfter rules are NOT explicitly ordered in the code, they could be programmaticly set in any random order. What I presented is just an accumulation of the what the user input in the GUI. It is the users intention to flip the order of the employees. What's important is to be able to process the processAfter's in some critical order to achieve the right output order
    The employee list is ordered according to the processAfter rules. Yes - correct
    Once the list is reordered, the employees in the list are in the order that they are to be processed.


    --- Update ---

    I thought I would have a crack at coding it, but you see my problem.

    import java.util.ArrayList;
    import java.util.LinkedList;
    import java.util.List;
     
     
    public class JavaTestPlugin 
    {
    	public static void main(String[] args) 
    	{
    		Employee one = new Employee(1);
    		Employee two = new Employee(2);
    		Employee three = new Employee(3);
    		Employee four = new Employee(4);
     
    		// Add to linked list in the order defined above
    		LinkedList<Employee> originalList = new LinkedList<>();
    		originalList.add(one);
    		originalList.add(two);
    		originalList.add(three);
    		originalList.add(four);
     
    		System.out.println("Before:");
    		for (Employee e : originalList)
    		{
    			System.out.println(e.employeeId); // [1, 2, 3, 4]
    		}
     
    		// set flags to flip the order
    		one.processAfterEmployeeId(three);
    		three.processAfterEmployeeId(four);
     
     
    		List<Employee> impactedEmployees = new ArrayList<>();
    		impactedEmployees.add(one);
    		impactedEmployees.add(three);
     
    		for (Employee sourceEmployee : impactedEmployees)
    		{
    			Employee targetEmployee = sourceEmployee.getProcessAfterEmployeeValue();
     
    			int sourceIndex = getIndex(originalList, sourceEmployee);
    			int targetIndex = getIndex(originalList, targetEmployee);
     
    			originalList.remove(sourceEmployee);
    			originalList.add(targetIndex, sourceEmployee);	
    		}
     
    		System.out.println("After:");
    		for (Employee e : originalList)
    		{
    			System.out.println(e.employeeId); 
    		}
    	}
     
    	private static int getIndex(LinkedList<Employee> list, Employee e)
    	{
    		for (int i = 0; i < list.size(); i++) 
    		{
    			Employee employee = list.get(i);
     
    			if (employee.employeeId == e.employeeId)
    			{
    				return i;
    			}
    		}
     
    		throw new RuntimeException("No id found");
    	}
    }

    public class Employee
    {
    	int employeeId;
    	Employee proessAfterEmployeeId;
     
    	public Employee(int employeeId)
    	{
    		this.employeeId = employeeId;
    	}	
     
    	public void processAfterEmployeeId(Employee id)
    	{
    		this.proessAfterEmployeeId = id;
    	}
     
    	public Employee getProcessAfterEmployeeValue()
    	{
     
    		return this.proessAfterEmployeeId;
    	}
    }

    Before:
    1
    2
    3
    4
    After:
    2
    1
    4
    3

    The After should read 2, 4, 3, 1 - but i'm just not sure how to to amend the list when iterating through each object. Kinda seems like I have to re-loop and shuffle all the items that have been previously set, but impacted by the current adjustment

  22. The Following User Says Thank You to alfa86 For This Useful Post:

    loncillosamm (July 13th, 2019)

  23. #12
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    22,638
    Thanks
    53
    Thanked 2,417 Times in 2,370 Posts

    Default Re: Ordering items but a bit more complex then just swapping items

    The processAfter rules are ordered to give the correct result. [B]Not sure I understood this question,
    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 employee list that is in the correct order.

    The question is: can the processAfter rules be placed in the correct order.

    have a crack at coding it
    Before writing any more code, make a list of the steps the program needs to take to solve the problem.
    Once you have a good design, then try coding it.

    I am assuming that the list of processAfter rules can be sorted into the correct order. Try to work out if that is true or not.
    If you don't understand my answer, don't ignore it, ask a question.

  24. The Following User Says Thank You to Norm For This Useful Post:

    loncillosamm (July 13th, 2019)

  25. #13
    Junior Member
    Join Date
    Jul 2019
    Posts
    14
    Thanks
    0
    Thanked 11 Times in 11 Posts

    Default Re: Ordering items but a bit more complex then just swapping items

    You're right, I've been playing around with this in my head. The rules can be sorted to achieve the final output order.

    If the rules are set like this initially:

    two.processAfterEmployeeId(one);
    one.processAfterEmployeeId(three);
    three.processAfterEmployeeId(four);

    To get the final order of [1,2 3,4] - > [4, 3, 1, 2]

    The execuiton of the order adjustment needs to take place in this order
    three.processAfterEmployeeId(four);
    one.processAfterEmployeeId(three);
    two.processAfterEmployeeId(one);

    What's the best way to be able to do this? Looks like we need a seperate linkedlist to store the rules and then to adjust the rule order based on the source and target employee values

  26. The Following User Says Thank You to alfa86 For This Useful Post:

    loncillosamm (July 13th, 2019)

  27. #14
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    22,638
    Thanks
    53
    Thanked 2,417 Times in 2,370 Posts

    Default Re: Ordering items but a bit more complex then just swapping items

    way to be able to do this
    Define a class to hold the rules and save objects of the class in a list that can be processed.
    If you don't understand my answer, don't ignore it, ask a question.

  28. The Following User Says Thank You to Norm For This Useful Post:

    loncillosamm (July 13th, 2019)

  29. #15
    Junior Member
    Join Date
    Jul 2019
    Posts
    14
    Thanks
    0
    Thanked 11 Times in 11 Posts

    Default Re: Ordering items but a bit more complex then just swapping items

    Logically though, is it enough to look at the run after value and sort that descending simply?

    for e.g if we take the following rules (note that I have created a very simplistic rule class for this issue)

    Rule rule1 = new Rule(2, 1);
    Rule rule2 = new Rule(1, 3);
    Rule rule3 = new Rule(3, 4);

    they should be sorted in order: rule3, rule2, rule1 - this is simply to take the "runAfter" value and sort the objects descending (4, 3, 1). Seems too simple, have I missed a trick amidst all of this?

    public class Rule 
    {
    	private int employeeId;
    	private int runAfter;
     
    	public Rule (int employeeId, int runAfter)
    	{
    		this.employeeId = employeeId;
    		this.runAfter = runAfter;
    	}
     
    	public int getEmployeeId()
    	{
    		return this.employeeId;
    	}
     
    	public int getRunAfter()
    	{
    		return this.runAfter;
    	}
    }

  30. The Following User Says Thank You to alfa86 For This Useful Post:

    loncillosamm (July 13th, 2019)

  31. #16
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    22,638
    Thanks
    53
    Thanked 2,417 Times in 2,370 Posts

    Default Re: Ordering items but a bit more complex then just swapping items

    Seems too simple
    Sometimes that happens.
    If you don't understand my answer, don't ignore it, ask a question.

  32. The Following User Says Thank You to Norm For This Useful Post:

    loncillosamm (July 13th, 2019)

  33. #17
    Junior Member
    Join Date
    Jul 2019
    Posts
    14
    Thanks
    0
    Thanked 11 Times in 11 Posts

    Default Re: Ordering items but a bit more complex then just swapping items

    it was too simple.

    the original list can be of any order, e.g 8,3,6,2 so ordering descending on the "after" value wont really work. Think I am stuck on the design of this.

  34. The Following User Says Thank You to alfa86 For This Useful Post:

    loncillosamm (July 13th, 2019)

  35. #18
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    22,638
    Thanks
    53
    Thanked 2,417 Times in 2,370 Posts

    Default Re: Ordering items but a bit more complex then just swapping items

    the "after" value
    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.
    If you don't understand my answer, don't ignore it, ask a question.

  36. The Following User Says Thank You to Norm For This Useful Post:

    loncillosamm (July 13th, 2019)

  37. #19
    Junior Member
    Join Date
    Jul 2019
    Posts
    14
    Thanks
    0
    Thanked 11 Times in 11 Posts

    Default Re: Ordering items but a bit more complex then just swapping items

    I think I've just done a full round and back to square one.

    I can't seem to think of a way to sort a list of rules the way that would give me the output.

    if I iterate around the rules, i can place the current processing item at a specific index in the list, but the one I am processing may have impacted other items that were previously moved (so they all need moving again) - can someone help me with a java example of this please?

  38. The Following User Says Thank You to alfa86 For This Useful Post:

    loncillosamm (July 13th, 2019)

  39. #20
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    22,638
    Thanks
    53
    Thanked 2,417 Times in 2,370 Posts

    Default Re: Ordering items but a bit more complex then just swapping items

    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 would be sorted based on the position in the lisst, not the id number.

    other items that were previously moved (so they all need moving again)
    Can you post an example?
    If you don't understand my answer, don't ignore it, ask a question.

  40. The Following User Says Thank You to Norm For This Useful Post:

    loncillosamm (July 13th, 2019)

  41. #21
    Junior Member
    Join Date
    Jul 2019
    Posts
    14
    Thanks
    0
    Thanked 11 Times in 11 Posts

    Default Re: Ordering items but a bit more complex then just swapping items

    Norm, yes I understand the position of the record needs to be used as opposed to the employee value. Given this example;

    // 8,3,6,2
    // rules in no particular order
    // rule1: move 8 after 6 (8 is at index 0)
    // rule2: move 3 after 8 (3 is at index 1)
    // rule3: move 2 after 3 (2 is at index 3)

    // if i start with the highest source index, which is rule 3, this gives me: 8,3,2,6
    // next is rule 2 (3 is already after 8 so nothing to do)
    // next is rule 1, this gives me: 3,2,6,8 (HOWEVER, notice that this has conflicted with rule 2 because 3 should be after 8)

    Can you see a way or algorithmn to apply the order of rules reliably? This is what I'm trying to seek help with

  42. The Following User Says Thank You to alfa86 For This Useful Post:

    loncillosamm (July 13th, 2019)

  43. #22
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    22,638
    Thanks
    53
    Thanked 2,417 Times in 2,370 Posts

    Default Re: Ordering items but a bit more complex then just swapping items

    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 programming problem. You need to try asking this question on a forum that is better at finding algorithms than I am.
    Try this one: http://www.coderanch.com/forums
    If you don't understand my answer, don't ignore it, ask a question.

  44. The Following User Says Thank You to Norm For This Useful Post:

    loncillosamm (July 13th, 2019)

  45. #23
    Junior Member
    Join Date
    Jul 2019
    Posts
    14
    Thanks
    0
    Thanked 11 Times in 11 Posts

    Default Re: Ordering items but a bit more complex then just swapping items

    Quote Originally Posted by Norm View Post
    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 programming problem. You need to try asking this question on a forum that is better at finding algorithms than I am.
    Try this one: http://www.coderanch.com/forums
    The solution for my example is 6,8,3,2

    This is an algorithm problem, i have posted on coderanch.

  46. #24
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    22,638
    Thanks
    53
    Thanked 2,417 Times in 2,370 Posts

    Default Re: Ordering items but a bit more complex then just swapping items

    If you don't understand my answer, don't ignore it, ask a question.

  47. #25
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    22,638
    Thanks
    53
    Thanked 2,417 Times in 2,370 Posts

    Default Re: Ordering items but a bit more complex then just swapping items

    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 in, the referenced employee is removed from the original list and added to the individual employee's list.
    If you don't understand my answer, don't ignore it, ask a question.

Page 1 of 2 12 LastLast

Similar Threads

  1. Disable items in JComboBox or ?
    By JavaCoderJ in forum Object Oriented Programming
    Replies: 1
    Last Post: October 26th, 2013, 07:58 PM
  2. menubars and menu items
    By runkerr in forum What's Wrong With My Code?
    Replies: 6
    Last Post: September 5th, 2013, 10:00 PM
  3. JComboBox help again but different help 75+ items in it
    By derekxec in forum AWT / Java Swing
    Replies: 7
    Last Post: August 27th, 2011, 06:53 PM
  4. Getting items from a table/checkboxes
    By beth in forum AWT / Java Swing
    Replies: 2
    Last Post: January 5th, 2011, 01:29 PM
  5. Different operation on Array
    By jempot in forum Collections and Generics
    Replies: 4
    Last Post: January 27th, 2009, 06:07 AM