Click here to Skip to main content
15,898,222 members
Home / Discussions / C#
   

C#

 
AnswerRe: difference b/w abstract method and interfaces Pin
PIEBALDconsult26-Nov-07 9:02
mvePIEBALDconsult26-Nov-07 9:02 
Questionthread synchronization Pin
invictus326-Nov-07 5:30
invictus326-Nov-07 5:30 
AnswerRe: thread synchronization Pin
Rob Philpott26-Nov-07 5:40
Rob Philpott26-Nov-07 5:40 
AnswerRe: thread synchronization Pin
Ennis Ray Lynch, Jr.26-Nov-07 7:16
Ennis Ray Lynch, Jr.26-Nov-07 7:16 
QuestionLine Segments [modified] Pin
Jim Warburton26-Nov-07 5:13
Jim Warburton26-Nov-07 5:13 
AnswerRe: Line Segments Pin
Skippums26-Nov-07 7:03
Skippums26-Nov-07 7:03 
GeneralRe: Line Segments Pin
Jim Warburton26-Nov-07 8:10
Jim Warburton26-Nov-07 8:10 
GeneralRe: Line Segments Pin
Skippums26-Nov-07 9:56
Skippums26-Nov-07 9:56 
Then just do what I suggested before, and use sorted dictionary to automatically sort the endpoints for you. You don't even have to use a hash if the class "Point3D" implements IComparable and IEquatable (you can just use the point directly as the key). It would be something like this...

public class Point3D : IComparable<Point3D>, IEquatable<Point3D> {
// this class must implement VALUE comparison (NOT REFERENCE!)
}

public class LineSegment {
public Point3D EndPoint1 { get; }
public Point3D EndPoint2 { get; }
public Vector Slope { get; }
}

public class SomeOther {

List<LineSegment> m_LineSegments = ...; // populate field
SortedDictionary<Point3D, IList<int>> m_EndPoints;

public void AddEndpoint(Point3D pt, int i) {
if (!m_EndPoints.ContainsKey(pt))
m_EndPoints.Add(pt, new List<int>());
m_EndPoints[pt].Add(i);
}

public void CombineLineSegments() {
m_EndPoints = new SortedDictionary<Point3D, IList<int>>(m_LineSegments.Count);
Point3D pt;
for (int i = m_LineSegments.Count - 1; i >= 0; --i) {
AddEndpoint(m_LineSegments[i].EndPoint1, i);
AddEndpoint(m_LineSegments[i].EndPoint2, i);
}
List<int[]> segsToCombine = new List<int[]>();
// Now iterate through the list of endpoints, checking each segment
// for direction coming out of that point. If direction matches, add
// the indices for those vectors to the segsToCombine list
// Finally, combine the segments found to be combinable.
}

}

Jeff
GeneralRe: Line Segments Pin
Jim Warburton29-Nov-07 4:23
Jim Warburton29-Nov-07 4:23 
AnswerRe: Line Segments Pin
Luc Pattyn26-Nov-07 7:10
sitebuilderLuc Pattyn26-Nov-07 7:10 
GeneralRe: Line Segments Pin
Jim Warburton26-Nov-07 7:57
Jim Warburton26-Nov-07 7:57 
GeneralRe: Line Segments Pin
Luc Pattyn26-Nov-07 8:32
sitebuilderLuc Pattyn26-Nov-07 8:32 
GeneralRe: Line Segments Pin
Jim Warburton26-Nov-07 8:59
Jim Warburton26-Nov-07 8:59 
QuestionHow to know which tree view node on master page is clicked on the form level Pin
ss.mmm26-Nov-07 5:09
ss.mmm26-Nov-07 5:09 
AnswerRe: How to know which tree view node on master page is clicked on the form level Pin
SABhatti26-Nov-07 8:53
SABhatti26-Nov-07 8:53 
QuestionUpdating controls from non-gui thread. Pin
Rob Philpott26-Nov-07 5:09
Rob Philpott26-Nov-07 5:09 
AnswerRe: Updating controls from non-gui thread. Pin
m@u26-Nov-07 5:21
m@u26-Nov-07 5:21 
GeneralRe: Updating controls from non-gui thread. Pin
Rob Philpott26-Nov-07 5:25
Rob Philpott26-Nov-07 5:25 
GeneralRe: Updating controls from non-gui thread. Pin
m@u26-Nov-07 5:38
m@u26-Nov-07 5:38 
AnswerRe: Updating controls from non-gui thread. Pin
Luc Pattyn26-Nov-07 6:23
sitebuilderLuc Pattyn26-Nov-07 6:23 
QuestionInserting into excel from C# Pin
GreekTreat26-Nov-07 5:06
GreekTreat26-Nov-07 5:06 
AnswerRe: Inserting into excel from C# Pin
GuyThiebaut26-Nov-07 5:16
professionalGuyThiebaut26-Nov-07 5:16 
GeneralRe: Inserting into excel from C# Pin
GreekTreat26-Nov-07 5:23
GreekTreat26-Nov-07 5:23 
AnswerRe: Inserting into excel from C# Pin
Aftab Sindhi26-Nov-07 5:23
Aftab Sindhi26-Nov-07 5:23 
QuestionArray Property Pin
papy-boom26-Nov-07 4:26
papy-boom26-Nov-07 4:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.