If you really want to trace through the list nodes like that, then
you're going to have to deal with all the CFC overhead, so a linked
list is probably best.  But you can still certainly use an
array-backed object for it that just spawns off node objects that
retain a reference.

method getNext() {
  return variables.array.getNodeAt(variables.index);
}

Not as internally elegant, to be sure, but certainly more efficient
when you don't need actual linked list behaviour.  Of course, if
that's all you need, then do it that way, because it'll be simpler
(though it won't be more efficient, particularly getHeadItem() and
similar methods that'd require a trace through the whole list).

cheers,
barneyb

On 9/13/05, S. Isaac Dealey <[EMAIL PROTECTED]> wrote:
> Well no, and here's an example that illustrates why:
> 
> <cfset first = listItem.getHeadItem()>
> <cfset next = first.getNextItem()>
> <cfif comparenocase(first.getOther(),next.getOther())>
>         these objects have different "other" values
> </cfif>
> 
> If I use a linked list, this code works as you might expect and I'm
> able to compare the "other" properties of two items in the list, and
> I'm still able to call getHeadItem() or getNext() or getLast() from
> either the "first" or "next" objects. If I use a single object which
> contains an array or a java Vector, then the getNext() function (and
> similar functions) will need to return either this or void. In either
> case I need a getCurrent() function to return the object at its
> current index, which won't contain the list methods.
> 
> <cfset first = listItem.getHeadItem().getCurrent()>
> <cfset next = listItem.getNext().getCurrent()>
> <cfif comparenocase(first.getOther(),next.getOther())>
>         ... these objects have different "other" values
> </cfif>
> 
> No the gap isn't horribly wide, but it is there.
> 

-- 
Barney Boisvert
[EMAIL PROTECTED]
360.319.6145
http://www.barneyb.com/

Got Gmail? I have 100 invites.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:218136
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to