473,416 Members | 1,609 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,416 software developers and data experts.

HasSet vs ArrayList and modelling issue

mickey0
142 100+
Hello,

I must implement a class MyMethod; read a method declaration from a file with a parser, and while parsing I must fill that MyMethod Object.

Now, at the moment this my objects are in this fashion:
Expand|Select|Wrap|Line Numbers
  1. //allow me all public to reduce code verbosity
  2. class MyMethod {
  3.            public Signature s;
  4.            public  String returnedType;
  5. }
  6. class MySignature {
  7.       public String name;
  8.       //public  List<MyVar> vars = new ArrayList<Var>();  
  9.         public  Set<MyVar> vars = new LinkedHashSet<MyVar>();  //eg, (int x, String s, int y)'
  10. }
  11. class MyVar {    //eg. 'int x'
  12.        public String id;  
  13.        public String type;
  14. }
  15.  
Now, in MySignature I used a Linked hashSet because I want to keep the order of insertion (and I know that I can't have two params with the same ID, here overrivde properly) since the Parser parser the list of parameters in the order they are written.
I want to keep a position field because I would like, given an id (eg, 'x'), find its position within a certain signature WITHOUT iterate over all list of parameters (I suppose this is slower). So:
- was it better to iterate on it (and better declare it as ArrayList) ? using arrayList I could avoid the position "problem", since I can retrieve it from iterating on the List.
- assuming to really need the position, where could I put it ? Within MyVar?
- assuming to use the Set, how can I override equals in MyVar to cope this situation (ie. no at most one MyVar with a certain Id)

thanks.
Sep 12 '10 #1
0 969

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Alex Ting | last post by:
Hi Everybody, I have an issue about deleting an object from an arrayList. I've bounded a datagrid using this code where it will first run through all of the code in loadQuestions() and bind a...
7
by: Dave | last post by:
Hi all, I have... using System.Collections; namespace MyApp.Templates { public class MyPage : System.Web.UI.Page { ArrayList MyArray = new ArrayList();
1
by: sd | last post by:
QUESTION: How can my ASP page - which uses language="VBScript" - pass a "System.Collections.ArrayList" object - as a parameter - to a C# method in the middle-tier ??? ----- Is it possible at...
4
by: Danny | last post by:
I am writing a program that will connect to a device and potentially retrieve 1000+ records at a time for processing. Every record will get processed and saved in a SQL Server database. I am...
4
by: Peter | last post by:
I run into this situation all the time and I'm wondering what is the most efficient way to handle this issue: I'll be pulling data out of a data source and want to load the data into an array so...
48
by: Alex Chudnovsky | last post by:
I have come across with what appears to be a significant performance bug in ..NET 2.0 ArrayList.Sort method when compared with Array.Sort on the same data. Same data on the same CPU gets sorted a...
6
by: Vinit | last post by:
Hi I am passing an arraylist to a c#/.net webmethod from a perl client using soap:lite. The trace shows the elements in the xml request. The arraylist input in the webmethod however does not...
3
by: Christopher H | last post by:
I've been reading about how C# passes ArrayLists as reference and Structs as value, but I still can't get my program to work like I want it to. Simple example: ...
1
tifoso
by: tifoso | last post by:
I searched here and only found somebody with a round-robin arraylist issue here but what they suggest I tried already and it doesn't work for me I hope somebody can shed some light Scenario: I'm...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.