File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

[Help] Grouping of array elements

 
Jake Lee
Greenhorn
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an array, say arrCode[] and there two fields under that: key, value.
Based on the values of keys, group all values into groups of same key values. and the result should be groups of arrays of same keys with corresponding values. Anyone has some sample code to accomplish this?
Thanks a lot.
J-
 
Layne Lund
Ranch Hand
Posts: 3061
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What have you done so far? Please post some code snippits that illustrate the work you have put into this program. Also, explain what problems you have encountered, and indicate the line number where you think something is wrong.
Keep coding!
Layne
 
John Lee
Ranch Hand
Posts: 2545
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like to me this is just a O(n) problem.
 
Jake Lee
Greenhorn
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here you go:
arr1[]
arr1[].id
arr1[].value
inside arr1:
arr2[].itemNo
arr2[].value
based on the values of ids in arr1, sort out unique ids and create same structure of the above hierarchy by putting arr2 elements into one arr2 when ids are same. Basically to eliminate duplicate ids...and regroup their children.
Any thoughts??
Jake
[ January 27, 2003: Message edited by: Jake Lee ]
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic