www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Cannot understand some codes in std.concurrency.

--bcaec520e869efd72604ace1b44c
Content-Type: text/plain; charset=ISO-8859-1

In concurrency.d (version 2.055, line 1247 - 1250) , there's some codes
related to internal implementation of List(T).

"
 Range opSlice()
        {
            return Range( cast(Node*) &m_first );
        }
"

What does this mean? m_first itself is Node *, then &m_first is Node **,
then we cast it back to (Node *)? Does it make sense?

If we change "&m_first" to "m_first", it still is weird, because in line
1169:
"
  property bool empty() const
            {
                return !m_prev.next;
            }
"

The list is empty when m_first is null, that is m_prev is null, not
m_prev.next is null.

Is my understanding of these codes completely wrong, or it is a bug in the
code?

Thanks.

--bcaec520e869efd72604ace1b44c
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div>In concurrency.d (version 2.055, line 1247 - 1250) , there&#39;s some =
codes related to internal implementation of List(T).=A0</div><div><br></div=
<div>&quot;</div><div>=A0Range opSlice()</div><div>=A0 =A0 =A0 =A0 {</div>=


<div>=A0 =A0 =A0 =A0 }</div><div>&quot;</div><div><br></div><div>What does = this mean? m_first itself is Node *, then &amp;m_first is Node **, then we = cast it back to (Node *)? Does it make sense?</div><div><br></div><div>If w= e change &quot;&amp;m_first&quot; to &quot;m_first&quot;, it still is weird= , because in line 1169:</div> <div><div>&quot;</div><div>=A0 property bool empty() const</div><div>=A0 = =A0 =A0 =A0 =A0 =A0 {</div><div>=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return !m_p= rev.next;</div><div>=A0 =A0 =A0 =A0 =A0 =A0 }</div></div><div>&quot;</div><= div><br></div><div>The list is empty when m_first is null, that is m_prev i= s null, not m_prev.next is null.=A0</div> <div><br></div><div>Is my understanding of these codes completely wrong, or= it is a bug in the code?</div><div><br></div><div>Thanks.</div><div><br></= div><div><br></div> --bcaec520e869efd72604ace1b44c--
Sep 14 2011