03.01.2013 Views

Chapter 1

Chapter 1

Chapter 1

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Dynamic buffers are also used to store global and rich text, derived from CEditableText,<br />

part of the Text and Text Attributes API defined in txt*.h headers. Segmented buffers are<br />

particularly efficient at handling the kind of operations required by intensive word processing.<br />

The editable text APIs include InsertL(), Read(), and Delete() with specifications<br />

similar to those of CBufBase. However, the position argument in all these functions is a<br />

character position, not a byte position: Unicode uses two bytes per character. The SDK<br />

includes full documentation on rich text, and a pretty example project in<br />

\Examples\AppFramework\Text.<br />

8.1.3 Collections<br />

A collection class is one that holds a number of objects. In Symbian OS, collections are<br />

provided by a wide range of arrays and lists. The definitions for arrays and lists and for their<br />

supporting classes can be found either in e32std.h or in e32base.h, (descriptor arrays<br />

are defined in badesca.h). All are documented in the SDK, many with example code<br />

fragments showing how they are used. This section summarizes the types of collection<br />

classes available, describes the key properties of the concrete collection classes, and<br />

provides a quick selection guide.<br />

What types of collection are available?<br />

RArray classes:<br />

� use flat storage only,<br />

� support sorting and searching using a comparator function and can ensure<br />

uniqueness,<br />

� provide specializations for common types, for instance, integers.<br />

CArray classes:<br />

� provide a choice of either flat or segmented storage,<br />

� support sorting and searching using a key specification and can ensure uniqueness,<br />

� provide several variants, for instance, fixed or variable size elements, packed data<br />

� are generally slower and can be less easy to use than the RArray classes.<br />

Descriptor arrays:<br />

� provide a choice of either flat or segmented storage<br />

� can contain 8-bit or 16-bit descriptors<br />

� support sorting and searching and can ensure uniqueness<br />

� provide variants that can store any type of descriptor or can hold pointers to the data.<br />

Linked lists:<br />

� support iterators for scanning through the list<br />

� are available as singly and doubly linked lists; the link object must be a member of the<br />

linked class.<br />

TFixedArray:<br />

� used when the number of elements is fixed and known at compile time<br />

� should be used instead of traditional C++ arrays because they provide bounds<br />

checking.<br />

TArray:<br />

� used for representing any array data in a generic way.<br />

What are the main concrete containers?

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!