Click here to Skip to main content
15,906,455 members
Home / Discussions / C#
   

C#

 
GeneralRe: Retreiving next autonumber value Pin
tonyonlinux17-Jan-10 18:39
tonyonlinux17-Jan-10 18:39 
AnswerRe: Retreiving next autonumber value Pin
PIEBALDconsult17-Jan-10 5:13
mvePIEBALDconsult17-Jan-10 5:13 
QuestionHelp with PictureBox.image updating from Webcam capture Pin
shutupsquare16-Jan-10 9:49
shutupsquare16-Jan-10 9:49 
AnswerRe: Help with PictureBox.image updating from Webcam capture Pin
Luc Pattyn16-Jan-10 10:03
sitebuilderLuc Pattyn16-Jan-10 10:03 
GeneralRe: Help with PictureBox.image updating from Webcam capture Pin
shutupsquare16-Jan-10 10:17
shutupsquare16-Jan-10 10:17 
AnswerRe: Help with PictureBox.image updating from Webcam capture Pin
shutupsquare16-Jan-10 10:08
shutupsquare16-Jan-10 10:08 
GeneralRe: Help with PictureBox.image updating from Webcam capture Pin
Luc Pattyn16-Jan-10 11:05
sitebuilderLuc Pattyn16-Jan-10 11:05 
GeneralRe: Help with PictureBox.image updating from Webcam capture Pin
shutupsquare16-Jan-10 12:56
shutupsquare16-Jan-10 12:56 
GeneralRe: Help with PictureBox.image updating from Webcam capture Pin
Luc Pattyn16-Jan-10 13:03
sitebuilderLuc Pattyn16-Jan-10 13:03 
Questionencapsulation understanding problems Pin
binn01916-Jan-10 6:41
binn01916-Jan-10 6:41 
AnswerRe: encapsulation understanding problems PinPopular
Jimmanuel16-Jan-10 7:11
Jimmanuel16-Jan-10 7:11 
GeneralRe: encapsulation understanding problems Pin
binn01924-Jan-10 0:02
binn01924-Jan-10 0:02 
QuestionNeed help with drawing circles on mouse click event in pictureBox Pin
Midex16-Jan-10 5:49
Midex16-Jan-10 5:49 
AnswerRe: Need help with drawing circles on mouse click event in pictureBox Pin
Luc Pattyn16-Jan-10 6:13
sitebuilderLuc Pattyn16-Jan-10 6:13 
AnswerRe: Need help with drawing circles on mouse click event in pictureBox Pin
Dan Mos16-Jan-10 7:53
Dan Mos16-Jan-10 7:53 
QuestionBackgroundWorker with anonymous methods ? Pin
Mohammad Dayyan16-Jan-10 4:06
Mohammad Dayyan16-Jan-10 4:06 
AnswerRe: BackgroundWorker with anonymous methods ? Pin
Nicholas Butler16-Jan-10 4:59
sitebuilderNicholas Butler16-Jan-10 4:59 
GeneralRe: BackgroundWorker with anonymous methods ? Pin
Mohammad Dayyan16-Jan-10 6:58
Mohammad Dayyan16-Jan-10 6:58 
QuestionHolding data in memory Pin
Bardy8516-Jan-10 0:22
Bardy8516-Jan-10 0:22 
AnswerRe: Holding data in memory Pin
OriginalGriff16-Jan-10 1:01
mveOriginalGriff16-Jan-10 1:01 
GeneralRe: Holding data in memory Pin
Bardy8516-Jan-10 1:16
Bardy8516-Jan-10 1:16 
GeneralRe: Holding data in memory Pin
N a v a n e e t h16-Jan-10 6:05
N a v a n e e t h16-Jan-10 6:05 
Bardy85 wrote:
Tools.DB.OL.Xtime.EMPLOYEE employee = new Tools.DB.OL.Xtime.EMPLOYEE();
if (listEMPLOYEE.Exists(p))
{
employee = listEMPLOYEE.Find(p);
}


This code is inefficient. listEMPLOYEE.Exists(p) loops through the items in the list to return the result. employee = listEMPLOYEE.Find(p); will again do a iteration on all items and leading into worst performance. You can do something like the following instead.
Tools.DB.OL.Xtime.EMPLOYEE employee = listEMPLOYEE.Find(p); // employee will be null if not found
return employee;

Bardy85 wrote:
There can be up to about 5000 or so Employee records.


How often do you search on this records? If it is quite frequent, your approach is inefficient. Because, list has sequential storage and searches will lead into O(n) complexity. In such cases, querying database will be efficient. If you still need to keep the items in memory, consider a much superior data structure than a normal list.

If you have a one to one mapping like, getting employee object from the employee name, use a Dictionary where name will be the key and employee instance will be the value. This will give you constant (O(1)) complexity. Another alternative is to use a sorted list and do binary search for lookup. This will lead into logarithmic complexity and quite efficient with huge recordsets.



Smile | :)

Best wishes,
Navaneeth

GeneralRe: Holding data in memory Pin
Dan Mos16-Jan-10 7:21
Dan Mos16-Jan-10 7:21 
GeneralRe: Holding data in memory Pin
Bardy8516-Jan-10 9:21
Bardy8516-Jan-10 9:21 
GeneralRe: Holding data in memory Pin
Luc Pattyn16-Jan-10 10:05
sitebuilderLuc Pattyn16-Jan-10 10:05 

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.