Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
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:42am
Comments
SAKryukov at 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

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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  
v3
Comments
VJ Reddy at 25-Apr-12 12:02pm
   
Good answer. 5!
SAKryukov at 25-Apr-12 12:07pm
   
Thank you, VJ.
--SA
Member 8845505 at 27-Apr-12 4:49am
   
Thanks you u answer it very well I tahnk you and may GOD bless U.
SAKryukov at 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)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 520
1 mhegazy94 460
2 Ravi Bhavnani 230
3 Kornfeld Eliyahu Peter 185
4 Shemeemsha RA 160
0 Sergey Alexandrovich Kryukov 7,205
1 OriginalGriff 6,801
2 CPallini 5,350
3 George Jonsson 3,644
4 Gihan Liyanage 2,797


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

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100