Click here to Skip to main content
Sign Up to vote bad
good
Hey Guy,
 
please i have 3 request.
 
1 .I don't really know how i can do in C# to block my listbox so that when the User gives the same name in TextBox that it reject it.in C#
 
2. My second request is about a ArrayList.

-I have without problem insert a list of evenement or action(for example: StandUP,Sleep,Eat,Work, answer ) in my Arraylist but i don't know how to make a Link or Relation between a diifferent action. I ask to sombody in the college he speak about a Tological Sort(). I don't no one thing about it.
 
Please I found one algorithm about it. But to transform it in C# language is so difficult for me.
Here is the Algorithme
 
Calculate network(working-packages A = {wP1..., wPn}, dependence Dep ⊂ A × A)
  A' ← TOPOLOGICAL-SORT(A,Dep)
  (now all dependent WPs stand behind their(her) presuppositions)
  for WP ∈ A' (in accordance with topological order)
  doif WP is the first task   
    then [ EarliestBegin(WP) ← 0
       else [ EarliestBegin(WP) ← max X ∈ WP mit (X,WP) ∈ Dep : EarliestEnds(X)
     ⌊ EarliestEnds(WP) ← EarliestBegin(WP) + Duration(WP)
  for WP ∈ A' (in accordance with reverse topological order)
  do ⌈ if WP is Last Task      
    then [ LaterEnds(WP) ← maximum project duration (or  EarliestEnds(WP))
       else [ LaterEnds(WP) ← min X ∈ WP mit (WP,X) ∈ Dep : LaterBegin(X)
     ⌊ LaterBegin(WP) ← LaterEnd(WP) - Duration(WP)
 

 

Can someboy Help me to understand it maybe to explain me the different step please. the code i will try firstly for myself.
 
Please how can i understand interpretate it
thanks in advance
Leonce
Posted 25 Apr '12 - 4:42

Comments
SAKryukov - 25 Apr '12 - 11:17
Why typing the algorithm here if it is more or less apparent that you did not understand it, otherwise you would at least explained the symbols introduced. You use the TOPOLOGICAL-SORT function as if it was already defined somewhere, so this is not an algorithm of topological sort, so what it is? I am not sure you know yourself. --SA

1 solution

The collection supporting uniqueness is, for example System.Collections.Generic.Dictionary<KEY, VALUE>; please see:
http://msdn.microsoft.com/en-us/library/xfhwa508.aspx[^].
 
The method TryGetValue can make you get a value indexed by some key or an information if it is already in a dictionary; and the methods ContainsKey (this one if very fast, of nearly O(1) complexity) and ContainsValue (can be slow) will check up what is there. You can keep all your values in parallel with the values in the control and check/add new values before adding them to UI.
 
Look at other generic collection types and read MSDN help pages on each to know when to use one or another:
http://msdn.microsoft.com/en-us/library/0sbxh9x2.aspx[^].
 
Now, about ArrayList. First, there is no need to use it for any new development. Instead, use System.Collections.Generic.List<T>:
http://msdn.microsoft.com/en-us/library/6sh2ey19.aspx[^].
 
All non-specialized non-generic collection types were rendered obsolete in the .NET Framework v.2.0, when generics were introduced. They are fine if they already work in fully-debugged legacy units, but using then in new development makes absolutely no sense, as they require less safe type casting. Generics were invented to eliminate those type casts. If you are not well familiar with generics, perhaps this is the first thing to read about right now.
 
But — the list type won't help you. The question about using the list to represent relations makes no sense, really. A list can represent only a list. You have to work with the Cartesian Square objects and the subsets of it which represent an arbitrary finite graph or a relation. As a simplest way to represent a Cartesian Square A x A you could simple use an array [N, N], where N represents a number of elements in the set, such as a set of the noted of a graph. I have more or less comprehensive explanation of representation of graphs and relations in my article:
Enumeration Types do not Enumerate! Working around .NET and Language Limitations[^].
 
Please see the section "3.6 Cartesian Square":
Enumeration Types do not Enumerate! Working around .NET and Language Limitations [3.6. Cartesian Square].
 
See also:
http://en.wikipedia.org/wiki/Cartesian_product[^],
http://en.wikipedia.org/wiki/Binary_relation[^].
 
—SA
  Permalink  
Comments
VJ Reddy - 25 Apr '12 - 12:02
Good answer. 5!
SAKryukov - 25 Apr '12 - 12:07
Thank you, VJ. --SA
Member 8845505 - 27 Apr '12 - 4:49
Thanks you u answer it very well I tahnk you and may GOD bless U.
SAKryukov - 27 Apr '12 - 10:13
You are very welcome. Good luck, call again. --SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 OriginalGriff 385
1 Sergey Alexandrovich Kryukov 348
2 Arun Vasu 345
3 Tadit Dash 228
4 Aarti Meswania 195
0 Sergey Alexandrovich Kryukov 9,955
1 OriginalGriff 7,589
2 CPallini 4,028
3 Rohan Leuva 3,422
4 Maciej Los 2,949


Advertise | Privacy | Mobile
Web01 | 2.6.130523.1 | Last Updated 25 Apr 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid