473,387 Members | 1,760 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

ArrayList of Objects

Hi,
I am running with a specific problem ,I have 2 arraylists of object types.I
need to compare the 2 arraylists and I have to figure out the first
sequence of common objects in each array starting from index 0,then I have to
takeout the common objects and then all other object from the second array
list.

Thx
Satya
Nov 17 '05 #1
3 1447
Satya,

The first sequence of common objects? Does it count if only one object
matches up with another object? Or does the sequence have to have some
length?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Satya" <Sa***@discussions.microsoft.com> wrote in message
news:9F**********************************@microsof t.com...
Hi,
I am running with a specific problem ,I have 2 arraylists of object
types.I
need to compare the 2 arraylists and I have to figure out the first
sequence of common objects in each array starting from index 0,then I have
to
takeout the common objects and then all other object from the second array
list.

Thx
Satya

Nov 17 '05 #2
Satya wrote:
I am running with a specific problem ,I have 2 arraylists of object types.I
need to compare the 2 arraylists and I have to figure out the first
sequence of common objects in each array starting from index 0,then I have to
takeout the common objects and then all other object from the second array
list.


Like Nicholas, I'm slightly confused as to what you're asking.

Could you give a few examples using lists of strings?

Jon

Nov 17 '05 #3
Satya,

I'm not completely sure, but I think what you're asking for is a
distinct union of two collections right? If so then try the following
code which takes two collections and returns a new collection
containing the result of the union.

public ICollection Union(ICollection lhs, ICollection rhs)
{
Hashtable table = new Hashtable();

foreach (object element in lhs)
{
if (!table.Contains(element))
{
table.Add(element, element);
}
}

foreach (object element in rhs)
{
if (!table.Contains(element))
{
table.Add(element, element);
}
}

return result.Values;
}

Brian

Satya wrote:
Hi,
I am running with a specific problem ,I have 2 arraylists of object types.I
need to compare the 2 arraylists and I have to figure out the first
sequence of common objects in each array starting from index 0,then I have to
takeout the common objects and then all other object from the second array
list.

Thx
Satya


Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: TT ( Tom Tempelaere ) | last post by:
Hi At one point in my application I have a single ArrayList object that I need to break up in two Arraylist objects: the beginning part up to an index, and the ending part from a certain index. I...
4
by: Hans De Schrijver | last post by:
I have a private ArrayList variable that holds objects of various types, though they're all derived from a common base class (User). What I would like to do is provide public accessor properties...
0
by: Just D. | last post by:
There is an interesting article - http://www.devhood.com/tutorials/tutorial_details.aspx?tutorial_id=542&printer=t It shows how to serialize the ArrayList of identical objects. I did it a year...
6
by: GrandpaB | last post by:
While writing this plea for help, I think I solved my dilemma, but I don't know why the problem solving statement is necessary. The inspiration for the statement came from an undocumented VB...
16
by: RCS | last post by:
So I have an ArrayList that gets populated with objects like: myAL.Add(new CustomObject(parm1,parm2)); I'm consuming this ArrayList from an ObjectDataSource and would like to have this support...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.