Re: Strange code in Queue class in .NET framework
- From: Erik Funkenbusch <erik@xxxxxxxxxxxxxxxxxxxxxx>
- Date: Sun, 2 Mar 2008 12:30:33 -0500
On Sun, 02 Mar 2008 17:54:03 +0100, cody wrote:
Hi folks, I had a look into the source code of the Enqueue(T item)
method of the generic Queue class in the .NET framework.
public void Enqueue(T item)
{
if (this._size == this._array.Length)
{
int capacity = (int) ((this._array.Length * 200L) / 100L);
..
isn't the last line the same as "int capacity = _array.Length * 2" ?
Did I miss something?
One possible reason for this might be as a sort of clever "high bandpass
filter". Meaning that if _array.Length * 200 > the amount an int can hold,
it will throw an exception, thus limiting the allocation size to 1/200th of
the size of an int.
.
- Follow-Ups:
- Re: Strange code in Queue class in .NET framework
- From: Jeroen Mostert
- Re: Strange code in Queue class in .NET framework
- References:
- Prev by Date: Strange code in Queue class in .NET framework
- Next by Date: Re: Strange code in Queue class in .NET framework
- Previous by thread: Strange code in Queue class in .NET framework
- Next by thread: Re: Strange code in Queue class in .NET framework
- Index(es):
Relevant Pages
|