# kjs Library API Documentation

Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# KJS::List Class Reference

Native list type. More...

`#include <types.h>`

Inheritance diagram for KJS::List:

[legend]
Collaboration diagram for KJS::List:

[legend]
List of all members.

## Public Member Functions

| List (ListImp *v)
| List (const List &v)
List & | operator= (const List &v)
void | append (const Value &val)
| Append an object to the end of the list.
void | prepend (const Value &val)
| Insert an object at the beginning of the list.
void | appendList (const List &lst)
| Appends the items of another list at the end of this one.
void | prependList (const List &lst)
| Prepend the items of another list to this one.
void | removeFirst ()
| Remove the element at the beginning of the list.
void | removeLast ()
| Remove the element at the end of the list.
void | remove (const Value &val)
void | clear ()
| Remove all elements from the list.
List | copy () const
| Returns a deep copy of the list.
ListIterator | begin () const
ListIterator | end () const
bool | isEmpty () const
int | size () const
Value | at (int i) const
| Retrieve an element at an indexed position.
Value | operator[] (int i) const
| Equivalent to at.

## Static Public Member Functions

List | dynamicCast (const Value &v)
| Converts a Value into an List.
const List | empty ()
| Returns a pointer to a static instance of an empty list.

## Friends

class | ListIterator

## Detailed Description

Native list type.

List is a native ECMAScript type. List values are only used for intermediate results of expression evaluation and cannot be stored as properties of objects.

The list is explicitly shared. Note that while copy() returns a deep copy of the list the referenced objects are still shared.

Definition at line 132 of file types.h.

## Member Function Documentation

List List::dynamicCast | ( | const Value & | v | ) | `[static]`

Converts a Value into an List.

If the value's type is not ListType, a null object will be returned (i.e. one with it's internal pointer set to 0). If you do not know for sure whether the value is of type List, you should check the isNull() methods afterwards before calling any methods on the returned value.

Returns:
  The value converted to an List

Definition at line 189 of file types.cpp.

References KJS::Value::imp(), KJS::Value::isNull(), and KJS::Value::type().

void List::append | ( | const Value & | val | ) |

Append an object to the end of the list.

Parameters:

  val | Pointer to object.

Definition at line 197 of file types.cpp.

Referenced by KJS::Error::create().

void List::prepend | ( | const Value & | val | ) |

Insert an object at the beginning of the list.

Parameters:

  val | Pointer to object.

Definition at line 202 of file types.cpp.

void List::appendList | ( | const List & | lst | ) |

| Appends the items of another list at the end of this one. Definition at line 207 of file types.cpp.

void List::prependList | ( | const List & | lst | ) |

| Prepend the items of another list to this one. The first item of `lst` will become the first item of the list. Definition at line 212 of file types.cpp.

void List::removeFirst | ( |  | ) |

| Remove the element at the beginning of the list. Definition at line 217 of file types.cpp.

void List::removeLast | ( |  | ) |

| Remove the element at the end of the list. Definition at line 222 of file types.cpp.

void List::clear | ( |  | ) |

| Remove all elements from the list. Definition at line 232 of file types.cpp.

List List::copy | ( |  | ) | const

| Returns a deep copy of the list. Ownership is passed to the user who is responsible for deleting the list then. Definition at line 237 of file types.cpp.

ListIterator List::begin | ( |  | ) | const

Returns:
  A KJS::ListIterator pointing to the first element.

Definition at line 242 of file types.cpp.

ListIterator List::end | ( |  | ) | const

Returns:
  A KJS::ListIterator pointing to the last element.

Definition at line 247 of file types.cpp.

bool List::isEmpty | ( |  | ) | const

Returns:
  true if the list is empty. false otherwise.

Definition at line 252 of file types.cpp.

int List::size | ( |  | ) | const

Returns:
  the current size of the list.

Definition at line 257 of file types.cpp.

Value List::at | ( | int | i | ) | const

Retrieve an element at an indexed position.

If you want to iterate trough the whole list using KJS::ListIterator will be faster.

Parameters:

  i | List index.

Returns:
  Return the element at position i. KJS::Undefined if the index is out of range.

Definition at line 262 of file types.cpp.

Value List::operator[] | ( | int | i | ) | const

| Equivalent to at. Definition at line 267 of file types.cpp.

const List List::empty | ( |  | ) | `[static]`

| Returns a pointer to a static instance of an empty list. Useful if a function has a List parameter. Definition at line 272 of file types.cpp.

The documentation for this class was generated from the following files:

- types.h
- types.cpp

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 13:09:27 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001