Synopsis|History

XList Reference

XList provides a wapper object to treat AppleScript's list as iterator, stack and queue.

Constructor Method

make

Meke an instance of empty XList.

make_with

Meke an instance of XList with given an AppleScript's list object.

make_with_list

A synonym of make_with

make_with_text

Meke an instance of XList with from a list splitting a text with a delimiter.

Methods for Iterator

next

return an item in the list next to the item obtained by previous next()

has_next

check whether next() can return a next item or not

current_item

The item obtained by previous next() is returned.

current_index

An index number of an item obtained by previous next() is returned.

decrement_index

Decrements the index of the item obtained by next(). i.e. same item can be obtained once more.

increment_index

Increments the index of the item obtained by next(). i.e. skip an item.

reset

Make next() return items form first.

Stack and Quene

push

Append an item at the end of the list.

pop

Obtain last item in the stored list, and remove the item.

unshift

Append an item at the beginning of the list.

shift

Obtain first item in the list and remove it.

Accessing List Items

count_items

Return number of elements

delete_at

Delete an item specified with an index number.

item_at

Obtain an item specified with an index number. When a list of indexes is passed as an argument, multiple items will be obtained.

items_in_range

Obtain items between two indexes.

set_item

set an item at a specified index.

set_item_at

set an item at a specified index.

exchange_items

Exchange items specified with indexes

has_item

Check whether the object "an_item" is included in the XList instance or not.

index_of

Obtain an index number of the object "an_item" in the XList instance.

all_items

return a copy of stored list.

list_ref

return the stored list.

add_from_list

Add each item contained passed list at end of the reciver's XList instance.

Conversion to Text

as_xtext_with

Join every elements with given a delimiters as XText

as_unicode_with

Join every elements with given a delimiters as Unicode text

as_text_with

A synonym of as_unicode_with. Join every elements with given a delimiters as Unicode text.

as_string_with

Join every elements with given a delimiters as string

Loop with Script Object

each

Call do handler of given script object with passing a reference to each item in the XList as an argument.

enumerate

Call do handler of given script object with each item in the XList as an argument.

map

Call do handler of given script object with each items in the list as and argument. A XList consisting of the results of do handler is returned.

map_as_list

Call do handler of given script object with each items in the list as and argument. An AppleScript's list of the results of do handler is returned.

Make a copy of the instance

shallow_copy

Make a new instance which share internal list with the original.The internal counter for the iterator will be copied.

deep_copy

Make a new instance which have copied internal list from the original.

iterator

Make a shallow copy with resetting the internal iterator counter.

Synopsis|History