Click here to Skip to main content
15,887,175 members
Home / Discussions / C#
   

C#

 
AnswerRe: Sending a command to an IEnumerable method [modified] Pin
harold aptroot23-Oct-09 10:08
harold aptroot23-Oct-09 10:08 
GeneralRe: Sending a command to an IEnumerable method Pin
Ian Shlasko23-Oct-09 10:33
Ian Shlasko23-Oct-09 10:33 
GeneralRe: Sending a command to an IEnumerable method Pin
harold aptroot23-Oct-09 10:35
harold aptroot23-Oct-09 10:35 
GeneralRe: Sending a command to an IEnumerable method Pin
Ian Shlasko23-Oct-09 10:50
Ian Shlasko23-Oct-09 10:50 
GeneralRe: Sending a command to an IEnumerable method Pin
harold aptroot23-Oct-09 10:55
harold aptroot23-Oct-09 10:55 
GeneralRe: Sending a command to an IEnumerable method Pin
Ian Shlasko23-Oct-09 11:13
Ian Shlasko23-Oct-09 11:13 
GeneralRe: Sending a command to an IEnumerable method Pin
harold aptroot23-Oct-09 11:19
harold aptroot23-Oct-09 11:19 
GeneralRe: Sending a command to an IEnumerable method Pin
Ian Shlasko23-Oct-09 12:12
Ian Shlasko23-Oct-09 12:12 
With a bintree, wouldn't deleting also be O(log n)? But retrieval gets worse, not better... You aren't searching for element N, which would be easy, but the Nth element... Element #6 could be the 4th one, and a bintree doesn't really support that kind of operation very easily, unless I'm missing something.

Maybe with a sort of skip-array, we could cut a little off the iteration...
struct
{
  int ElementValue  // Actual value
  int SkipForward   // Number of blanks following this element
  int SkipBackwards // Number of blanks preceding this element
}


So for deleting, you jump straight in... But also jump forwards and backwards to "connect" the adjacent non-removed elements. Then when you need the Nth element, instead of just doing a flat iteration, you follow the SkipForward to jump through the array like a linked list.

For efficiency, could actually use three arrays instead of a struct, so between runs it's trivial to zero out the two skip arrays without changing the ElementValue array.

Still O(n^2), but less hops... It would take more operations for each removal, but with a large enough set, it might still be faster. An improvement, but not a generation leap, so to speak.

Proud to have finally moved to the A-Ark. Which one are you in?
Developer, Author (Guardians of Xen)

GeneralRe: Sending a command to an IEnumerable method Pin
harold aptroot23-Oct-09 12:23
harold aptroot23-Oct-09 12:23 
GeneralRe: Sending a command to an IEnumerable method Pin
Ian Shlasko23-Oct-09 12:27
Ian Shlasko23-Oct-09 12:27 
GeneralRe: Sending a command to an IEnumerable method Pin
Lutosław23-Oct-09 23:55
Lutosław23-Oct-09 23:55 
GeneralRe: Sending a command to an IEnumerable method Pin
Lutosław24-Oct-09 1:18
Lutosław24-Oct-09 1:18 
GeneralRe: Sending a command to an IEnumerable method Pin
Lutosław24-Oct-09 1:04
Lutosław24-Oct-09 1:04 
Answer[SOLVED] Sending a command to an IEnumerable method Pin
Lutosław23-Oct-09 23:51
Lutosław23-Oct-09 23:51 
GeneralRe: [SOLVED] Sending a command to an IEnumerable method Pin
harold aptroot24-Oct-09 1:22
harold aptroot24-Oct-09 1:22 
QuestionWhere to write application files on Vista/W7 Pin
BRShroyer23-Oct-09 8:05
BRShroyer23-Oct-09 8:05 
AnswerRe: Where to write application files on Vista/W7 Pin
Ian Shlasko23-Oct-09 8:13
Ian Shlasko23-Oct-09 8:13 
GeneralRe: Where to write application files on Vista/W7 Pin
BRShroyer23-Oct-09 8:19
BRShroyer23-Oct-09 8:19 
GeneralRe: Where to write application files on Vista/W7 Pin
Ian Shlasko23-Oct-09 8:46
Ian Shlasko23-Oct-09 8:46 
QuestionHow to control speakers individually? Pin
Gedon_Sarep23-Oct-09 8:03
Gedon_Sarep23-Oct-09 8:03 
QuestionAutomated save as webpage completed by C# Pin
Nguyễn Đức Thiện23-Oct-09 6:51
Nguyễn Đức Thiện23-Oct-09 6:51 
AnswerRe: Automated save as webpage completed by C# Pin
Not Active23-Oct-09 7:05
mentorNot Active23-Oct-09 7:05 
GeneralRe: Automated save as webpage completed by C# Pin
Nguyễn Đức Thiện23-Oct-09 7:12
Nguyễn Đức Thiện23-Oct-09 7:12 
AnswerMessage Closed Pin
23-Oct-09 7:45
stancrm23-Oct-09 7:45 
GeneralRe: Automated save as webpage completed by C# Pin
Nguyễn Đức Thiện23-Oct-09 15:31
Nguyễn Đức Thiện23-Oct-09 15:31 

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.