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.
> Sure you would. The former is exactly what I'd envision.
> Just like
> you a Vector (though without the Iterator). The array
> would be
> totally hidden inside the Vector CFC - the calling code
> would never
> know there's an array in there (vs a linked list, or a
> backing DB
> table). Just the index-based accessors and mutators.
> cheers,
> barneyb
> On 9/13/05, S. Isaac Dealey <[EMAIL PROTECTED]> wrote:
>> > How about just an Array CFC that has an internal array
>> > variable.
>> > Since it's the CFC being passed, you get the
>> > pass-by-reference. You
>> > could build whatever extra methods you wanted on it as
>> > well as the
>> > required accessor/modifier methods. Basically you'd
>> > be
>> > rewriting
>> > java.util.Vector with a CFC so that CF won't clone it
>> > all
>> > over the
>> > place like it does with real Vectors.
>>
>> > cheers,
>> > barneyb
>>
>> That's possible... Not what I had in mind, but it's
>> possible... It
>> doesn't encapsulate the instructions the way I was
>> imagining. Here's a
>> crude example (pardon the lack of appropriate i18n,
>> etc.):
>>
>> <cfset item = session.cart.getHeadItem()>
>> <cfloop condition="isObject(item)">
>> <tr>
>> <td>#item.getName()#</td>
>> <td>#item.getQty()#</td>
>> <td>$#item.getPrice()#</td>
>> <td>$#item.getSubtotal()#</td>
>> </tr>
>> <cfset item = item.getNextItem()>
>> </cfloop>
>>
>> comparable array version
>>
>> <cfloop index="x" from="1" to="#arraylen(session.cart)#">
>> <cfset item = session.cart[x]>
>> <tr>
>> <td>#item.getName()#</td>
>> <td>#item.getQty()#</td>
>> <td>$#item.getPrice()#</td>
>> <td>$#item.getSubtotal()#</td>
>> </tr>
>> </cfloop>
>>
>> I'm not sure if this makes any sense, but I kinda like
>> the
>> encapsulation of the former -- it seems cleaner to me...
>> Even if I
>> wrapped the latter in a separate CFC to manage a java
>> Vector I still
>> wouldn't get that same kind of encapsulation.
s. isaac dealey 954.522.6080
new epoch : isn't it time for a change?
add features without fixtures with
the onTap open source framework
http://www.fusiontap.com
http://coldfusion.sys-con.com/author/4806Dealey.htm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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:218133
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=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54