Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more: , +
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

C#
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
Comments
Sergey Alexandrovich Kryukov 25-Apr-12 11:17am    
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
 
Share this answer
 
v3
Comments
VJ Reddy 25-Apr-12 12:02pm    
Good answer. 5!
Sergey Alexandrovich Kryukov 25-Apr-12 12:07pm    
Thank you, VJ.
--SA
stefan from germany 27-Apr-12 4:49am    
Thanks you u answer it very well I tahnk you and may GOD bless U.
Sergey Alexandrovich Kryukov 27-Apr-12 10:13am    
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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900