[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: ITP: Music123



From: Anthony Towns <aj@azure.humbug.org.au>
> It depends how it's implemented. A naive implementation could very easily
> be O(N^2) (if you're removing k non-music-files, and each removal is O(n)
> operations (like a memmove for an array deletion), eg)
>
> For example:
> int i;
> for (i = n-1; i >= 0; i--) {
>  if (is_not_music(filename[i])) {
>   n--;
>   memmove(filename+i, filename+i+1, n-i);
>  }
> }

That's basically what the code looks like, only with an vector class hiding
the memmove. My probable course of action is avoiding adding the files to
the list in the first place.

--
David Starner - dstarner98@aasaa.ofe.org
"The pig -- belongs -- to _all_ mankind!" - Invader Zim






Reply to: