VList: Difference between revisions
Content added Content deleted
(J) |
m (→{{header|J}}) |
||
Line 999: | Line 999: | ||
=={{header|J}}== |
=={{header|J}}== |
||
A vlist preallocates storage in increasing powers of 2. The "head" of the vlist is in the last (largest) storage block. Here we define a class with methods <code>unshift</code> (which adds to the "head" of the vlist), <code>shift</code> (which removes from the "head" of the vlist), <code>size</code> (which tells us how many elements the vlist currently contains), and get (which retrieves the nth element from the vlist): |
A vlist preallocates storage in increasing powers of 2. The "head" of the vlist is in the last (largest) storage block. Here we define a class with methods <code>unshift</code> (which adds to the "head" of the vlist), <code>shift</code> (which removes from the "head" of the vlist), <code>size</code> (which tells us how many elements the vlist currently contains), and <code>get</code> (which retrieves the nth element from the vlist): |
||
<lang J>coclass 'vlist' |
<lang J>coclass 'vlist' |