|
|
Ippacciani wrote: I'm new on this site.
Welcome to CodeProject
Ippacciani wrote: I'm an Italian student
Ippacciani wrote: I have to implement in Java
Have you not heard about the Microsoft .NET Platform yet? That's what this forum is for not Java. Actually this site is focused on the Windows platform. I don't believe there even is a Java forum. You are probably better off finding another site for Java questions. At the least you should probably ask your question in the "General Discussions" forum. Good luck.
led mike
|
|
|
|
|
BTW, why does CP now describe itself as "Your Development Resource?" It creates the impression that it deals with all development rather than Microsoft-centric development. Maybe this is why this guy is asking about Java?
Kevin
|
|
|
|
|
It feels a bit silly answering a message that isn't there any more, but here it goes
anyway:
1.
there was no need to mention Java, it does not seem essential in your quest; and a lot of
people here are allergic to it, the "not invented here" syndrome you know.
2.
Maybe this link will show how collections typically are implemented:
http://www.itu.dk/research/c5/[^]
3.
just keep posting questions in whatever forum seems appropriate, don't get discouraged
by some reactions. And please don't delete messages; if you need to, you can modify an
existing message, adding text, and striking through stuff.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Hello,
How can I create a sorted list in .Net?
Something like:
SortedList<string> L = new SortedList<string>();
L.Add("B");
L.Add("A");
Now L[0] should contain "A".
I found class SortedList<key, value=""> but this requires two types which seems an overkill to me.
Thanks in advance,
Kees Vermeulen
|
|
|
|
|
Pretty much any collection in .NET can be sorted with the aid of the IComparable interface.
|
|
|
|
|
Pete,
I want the sort order to be maintained so that new items are inserted at the right position in the list without calling List<>.Sort every time.
Kees
|
|
|
|
|
Well, you wouldn't do this since the more items you add to the collection, the longer the process of adding a single item would take.
Sorting is a presentation layer requirement, not something you normally do as part of data storage. If you wanted the list sorted, you would normally call a method on the collection to return the sorted list.
|
|
|
|
|
Thanks for your answer.
I have many occasions in which I use sorted lists! For example to prevent insertion of duplicate items and for fast retrieval of existing items.
For example, in my situation I have a function parser which can handle various predefined functions. These functions are simply strings and I want to test if a certain string is a predefined function. Looking up a string in a sorted list would be much faster than doing so from an unsorted list.
Kees
|
|
|
|
|
KeesVer wrote: prevent insertion of duplicate items and for fast retrieval of existing items
Don't use a sorted list for this. This is what a key/value paired collection or is for, such as a Dictionary.
|
|
|
|
|
Thanks,
I do not always have a key AND a value. Sometimes the Key IS the Value and therefore using a Dictionary or SortedList is cumbersome. However, from your answers I conclude that under .Net this is the way to go.
Kees
|
|
|
|
|
I would then suggest composing a new class that contains a Dictionary, but adds overloads to methods such as Add, in which you use the value as a key.
|
|
|
|
|
If you find the .NET collections not convenient or flexible enough for your tastes be aware that there are some well-tested alternative open source collection libraries around, e.g.,
PowerCollections[^]
Welcome to Power Collections, A Community Project to Develop the Best Public License type safe Collection Classes for .NET. Power Collections makes heavy use of .NET Generics. The goal of the project is to provide generic collection classes that are not available in the .NET framework. Some of the collections included are the Deque, MultiDictionary, Bag, OrderedBag, OrderedDictionary, Set, OrderedSet, and OrderedMultiDictionary.
and
The C5 Generic Collection Library[^]
C5 is a library of generic collection classes for C# and other CLI languages and works with Microsoft .Net version 2.0 and Mono version 1.2 and later.
C5 provides functionality and data structures not provided by the standard .Net System.Collections.Generic namespace, such as persistent tree data structures, heap based priority queues, hash indexed array lists and linked lists, and events on collection changes. Also, it is more comprehensive than collection class libraries on other similar platforms, such as Java. Unlike many other collection class libraries, C5 is designed with a strict policy of supporting "code to interface not implementation".
I myself have been using PowerCollections in the past few days in connection with user role management. PowerCollections is a little easier to use as it's a natural extension of the framework classes. C5 is more powerful but rather more esoteric. Also PowerCollections is better documented with intellisense tooltips and so on. Both are accompanied by unit tests.
Kevin
|
|
|
|
|
Hi Kees,
1.
SortedList is a HashTable or Dictionary, so it stores (Key,Value) pairs. If you don't
need values, you could specify "null" for all of them.
2.
Yes, I found the collection names a bit confusing; I would expect a Dictionary to always be
sorted (as in: Van Dale) but that is not how .NET sees it.
3.
Maybe this will interest you:
http://www.itu.dk/research/c5/[^]
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Luc Pattyn wrote: I found the collection names a bit confusing; I would expect a Dictionary to always be
sorted
Well, that's probably just because real world dictionaries are sorted in order for us to find anything in them. If you look at how a paper dictionary works, a sorted list would be digital equivalent, but if you instead concentrate on the purpose of a dictionary, i.e. to find single items in a large collection, the naming of the class makes more sense.
Experience is the sum of all the mistakes you have done.
|
|
|
|
|
Yes, I know what they do, but why choose names that are counterintuitive, i.e.
don't match real-world terms.
I would prefer a Map for a .NET Dictionary, and a SortedMap for a .NET SortedList
(it isn't a sorted List, in .NET terms it is a sorted dictionary).
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Luc Pattyn wrote: Yes, I know what they do, but why choose names that are counterintuitive, i.e.
don't match real-world terms.
They match the real-world items if you think of them from a certain point of view.
Computerised real-world concepts often mimic only some aspects but not all. If you take radio buttons for example, they pop out just like buttons on a real radio, but you can't turn them to change the preset frequency.
Luc Pattyn wrote: I would prefer a Map for a .NET Dictionary
A map to me is something that describes two dimensional geographical data, so that would be even more confusing...
Luc Pattyn wrote: and a SortedMap for a .NET SortedList
(it isn't a sorted List, in .NET terms it is a sorted dictionary).
The internal storage for a SortedList is a pair of arrays, so it actually is a sorted list.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hello together,
I start a new process inside a system process (IIS web service) like this:
Dim pProcess As New System.Diagnostics.Process
Dim sArguments As String = ""
pProcess.StartInfo.FileName = "process.exe"
pProcess.StartInfo.Arguments = sArguments
pProcess.StartInfo.WorkingDirectory = "c:\temp"
pProcess.StartInfo.CreateNoWindow = False
pProcess.StartInfo.WindowStyle = ProcessWindowStyle.Normal
pProcess.Start()
Process is startet, but the window is not visible on the desk. I think, the problem is the system process as father. If the new process throws an exception, the window is visible.
Did anybody know, how I can make the process window visible on the desk? Can be some nice parameters on the process object himself or inside the process (source code is written in VB.NET).
Thanks
Stephan
\\\| \\ - -
( @ @ )
+---------------oOOo-(_)-oOOo-----------------+
| Stephan Pilz stephan.pilz@stephan-pilz.de |
| <a href="http://www.stephan-pilz.de">www.stephan-pilz.de</a> |
| ICQ#: 127823481 |
+-----------------------Oooo------------------+
oooO ( )
( ) ) /
\ ( (_/
\_)
|
|
|
|
|
So why would a Web Service be starting an interactive process on the server?
Since services run under they're own desktop, the window is getting created, just on a desktop that is hidden from view.
|
|
|
|
|
Because the web service is only a wrapper to business logic process and I want to see some trace messages from the BL-process. Store this messages in event log or a log file is not a solution for me.
Please don't ask why I do it so, because there is no other way. Please give me hints, tricks or ideas to solve my problem. It's not possible to change the infrastructure.
Stephan
\\\| \\ - -
( @ @ )
+---------------oOOo-(_)-oOOo-----------------+
| Stephan Pilz stephan.pilz@stephan-pilz.de |
| <a href="http://www.stephan-pilz.de">www.stephan-pilz.de</a> |
| ICQ#: 127823481 |
+-----------------------Oooo------------------+
oooO ( )
( ) ) /
\ ( (_/
\_)
|
|
|
|
|
Stephan Pilz wrote: Please don't ask why I do it so, because there is no other way
Keep that up and you'll be completely on your own in no time.
Since your ASP.NET WEb Service cannot show a user interface on the server hosting it, you'll have to supply a UI some other way, like a normal Windows Forms app running a custom TraceListener exposed as a singleton class inside a WCF Service.
Well, a rather convoluted solution would be to create your own implementation of a TraceListener, setup as a singleton, in a host application that shows all incomming trace messages. This trace listener would be exposed through the host as a remotable object, or do the same thing as a WCF service hosted in a Windows Form or Console application.
In your Web Service Global.asax page, in possibly the Application_Start, Session_Start, or Application_BeginRequest handlers, you'd get the reference to the custom trace listener, add it to the Trace.Listeners collection in your Web Service, handle the call and output your trace messages.
The custom TraceListenerwould output any messages to a TextBox, Console window, log to a file, ..., whatever you want.
The downside is that this is a convoluted solution. The up side is that is lets you deploy your web service to multiple servers and still log all trace messages to a single window on a single monitoring workstation.
|
|
|
|
|
I'm using visual studio 2005. I designed a user-defined DataSet using the DataSet designer. I inserted a table and wanted one of its columns to be hidden (not emitted when the DataSet is serialized to XML). The designer by default sets the column mapping to <i>Element</i>. I found no method in the designer (or the property sheet) to set the column mapping. I tried to override this setting by hand editing the .cs (, I'm using c#,) file generated by the designer and changed the mapping type (, the fourth parameter,) in the DataColumn constructor to <i>Hidden</i>. However each time I make any slight change in the DataSet designer, it regenerates the .cs file reverting my change back to the <i>Element</i> setting.
Any idea about how to overcome this problem?
|
|
|
|
|
MSK61 wrote: However each time I make any slight change in the DataSet designer, it regenerates the .cs file reverting my change back to the Element setting.
Any idea about how to overcome this problem?
How often do you change the schema? If your in development and that's why the schema is changing frequently why worry about hiding the column? Just wait until you are finished and then change the class.
led mike
|
|
|
|
|
I'm looking for a free obfuscator tool.
I tried Aspose and Skater Lite, but each one of them throws an exception while processing my assembly.
My assembly doesn't contain reflection.
Do you know any other free (or light versions) of obfuscators (especialy for .NET Compact Framework 1.0) ?
My english is not so good. Please, correct my errors.
Best regards, Alexey.
|
|
|
|
|
|