|
No problem.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
|
The same way you would do it on paper. Create a List of all the points in the graph and then draw a line from the first to the last, passing through each intermediate point. You can do this by using the Graphics Class[^], or search Google for some other utility classes that may help you.
Veni, vidi, abiit domum
|
|
|
|
|
I do not plot as in the picture. No numbers only lines
|
|
|
|
|
Sorry, but I do not know what you mean.
Veni, vidi, abiit domum
|
|
|
|
|
No lines. does not seem spots
|
|
|
|
|
Sorry, but that is no more clear. Try explaining in detail what you are having trouble with. And if it is a matter of translation, then perhaps you can get someone else to help with the English.
Veni, vidi, abiit domum
|
|
|
|
|
self.dots=[]
for i in range(0,num_dots)
if (condition)
self.dots.append("fix",dots[i])
else
self.dots.append("free",dots[i])
Hi all.I have a part of my project created in python and i would like to rewrite in c#.In python i used a list (self.dots) to have every item ordered with its string value.in c# i don't know how to obtain the same thing.i need to check if each item is free or fix but following the order i previously established.
|
|
|
|
|
|
Perfect.thank you very much
|
|
|
|
|
Take a look at the SortedList[^] or SortedDictionary[^] classes.
other than that there is also a "Sort" Method on the Default List[^] object. Where you can pass a comparer object with your logic how to sort the items contained in that list.
Besides, I'm not really sure what you're trying to accomplish. So I can't guarantee those are what you're looking for 
|
|
|
|
|
Ok.thank you very much.Do you know how the sorteddictionary is ordered? by adding elements?i am looking up on the web in the meanwhile.
|
|
|
|
|
In the SortedDictionary sorting is made on the key. And you can't have the same key multiple times in the same dictionary.
Note that for both the SortedDictionary and the SortedList the object on which the sorting should happen has to implement the IComparable Interface or you need to assign an IComparer Implementation that takes care of the sorting for you.
|
|
|
|
|
ok i think i have undestood.I only need how to get value by index.is the following the only way?and do you think is it too slow?
sortedDictionary[sortedDictionary.ElementAt(index).Key] = value;
thank you very much
|
|
|
|
|
If you want to use the dictionary this should suffice. But that's just from the top of my head:
sortedDictionary.ElementAt(index).Value = value;
There should be no need to access the dictionary twice just to set the value.
|
|
|
|
|
|
If you wan't to use the index instead of the key take another look at the SortedList.
There is an example of how to access an element by the index (Hint: myList.GetByIndex(i) )
There are places where a Dictionary is useful and then there are places where List is useful. That's why both those types exist.
|
|
|
|
|
ok thank you very much. now i will try both to understand which is the best solution for me
|
|
|
|
|
i didn't know SortedDictionary<tkey, tvalue="">.I'm searching for information in internet.Is it the right way?
Thank you
|
|
|
|
|
Whether a SortedDictionary, or a SortedList, is "right," depends on the requirements of your code.
Does the solution you are creating require frequent immediate access to a sorted collection of data, and is that data "coming in" in a way where it's "unsorted" ?
If that's the scenario, then perhaps you are required to sort the data every time you add a new item to it.
On the other hand, if your need for access to sorted data is intermittent, perhaps you'll get better performance if you sort on demand.
Keep in mind that a SortedList is a collection of Key/Value Pairs, and there is a cost in memory, and computation, for maintaining it compared to a simple Generic List, just as there is for using a SortedDictionary.
“I'm an artist: it's self evident that word implies looking for something all the time without ever finding it in full. It is the opposite of saying : 'I know all about it. I've already found it.'
As far as I'm concerned, the word means: 'I am looking. I am hunting for it. I am deeply involved.'”
Vincent Van Gogh
|
|
|
|
|
You need to be clear what you mean by "ordered with its string value" (at least for folks like me who don't use Python).
If you mean sort alpha-numerically, then YourList.Sort(); will take care of that for you in .NET C#.
If you doing some kind of ordering beyond the default ("natural" ordering of elements based on their Type), then, if you are using C# 2.0, not 3.0, that's is important to know, also.
Also of interest is whether you are sorting in-place, or perhaps wish ... using Linq ... to return a new List sorted/ordered-by whatever without changing the source List.
“I'm an artist: it's self evident that word implies looking for something all the time without ever finding it in full. It is the opposite of saying : 'I know all about it. I've already found it.'
As far as I'm concerned, the word means: 'I am looking. I am hunting for it. I am deeply involved.'”
Vincent Van Gogh
|
|
|
|
|
Sorry.I need to create a sorteddictionary or a sortedlist to have my items ordered by the key "dot" that is a guid .in python you don't need that,you only create a list with different types and it is ordered.thank you anyway
|
|
|
|
|
If you need to use a Dictionary, then something like Dictionary<Guid,string> should be fine.
For a discussion of issues with sorting a Dictionary, see this thread that I started in November, this year: [^].
Using a generic List would allow for more than one list item with the same value; using a Dictionary you must have a unique Key for each item, but you can have multiple items with the same Value. What exactly is required ?
If you choose to use a SortedDictionary, or SortedList, you may wish to do some research on their differences; the best single summary of that I know is:[^].
“I'm an artist: it's self evident that word implies looking for something all the time without ever finding it in full. It is the opposite of saying : 'I know all about it. I've already found it.'
As far as I'm concerned, the word means: 'I am looking. I am hunting for it. I am deeply involved.'”
Vincent Van Gogh
modified 27-Dec-13 19:07pm.
|
|
|
|
|
thank you very very much for you explanation.i think i will use SortedList .the reason is that i always have different keys because they are Guid and a string value for each key ("fix" or "free").then i think it is easy to change the value of some keys when needed,and to iterate ,to remove elements etc etc.i only have to use casting for the keys.thank you very much again .you have been very kind
|
|
|
|
|
Hi all.i tried to use SortedList but unfortunatly it didn't meeet my needs.It is too difficult to make my object implementing icomparable.In the end i preferred to use two normal List,one for my dots and the other for the associated string The number of elements in both lists is the same and i only have to remember to update both of them when adding or removing elements from one of the lists.they are linked by the index of elements and everithing is easyer and faster.However, thanks for your advices
|
|
|
|