WrappedList ライブラリ

- 目次 -


概要 - Abstract

このライブラリ data.WrappedList は、リスト型のデータ構造を提供します。

このモジュールでは、リストのデータを保持するジェネリック構造体 WrappedList と、それに対してデータを出し入れするジェネリック関数 add, remove などが提供されます。

なお、この data.WrappedList では、要素を DataWrapper 構造体でラッピングして保持する実装になっています。
そのため WrappedListでは、 data.List とは異なり、配列を要素として扱う事ができます。

反面、要素の出し入れの際に DataWrapper 構造体へのラッピング処理を伴うため、そのオーバーヘッドの分だけ、List よりも処理が重くなります。
従って、要素が配列でない場合には、WrappedList よりも List の使用が推奨されます。


目次 - Index

struct WrappedList<Type>
リスト構造体です。リストのデータを保持します。
void clear<Type>( WrappedList<Type> &list )
要素を全て削除します。
int size<Type>( WrappedList<Type> &list )
使用中のサイズを返します。
void add<Type>( WrappedList<Type> &list, Type value )
リストの末尾に要素を追加します。
Type get<Type>( WrappedList<Type> &list, int index )
特定インデックスの要素を取得します。
void set<Type>( WrappedList<Type> &list, int index, Type element )
特定インデックスの要素を代入します。そのインデックスの位置にあった要素は上書きされます。
Type insert<Type>( WrappedList<Type> &list, int index, Type value )
特定インデックスに要素を挿入します。そのインデックスの位置にあった要素は、次のインデックスの位置に移動します。また、それ以降の全ての要素も、インデックスが後方に 1 ずつ移動します。
bool contains<Type>( WrappedList<Type> &list, Type element )
リストが指定された要素を含んでいるか判定します。
Type removeAt<Type>( WrappedList<Type> &list, int index )
特定インデックスの要素を削除します。
void remove<Type>( WrappedList<Type> &list, Type element )
指定された要素を削除します。複数存在する場合は、最初のものだけが削除されます。
void removeAll<Type>( WrappedList<Type> &list, Type element )
指定された要素を全て削除します。
int indexOf<Type>( WrappedList<Type> &list, Type element )
指定された要素を、先頭から後方検索し、存在すればそのインデックスを、存在しなければ-1を返します。
int indexOf<Type>( WrappedList<Type> &list, Type element, int from )
指定された要素を、指定インデックスの位置から後方検索し、存在すればそのインデックスを、存在しなければ-1を返します。
int lastIndexOf<Type>( WrappedList<Type> &list, Type element )
指定された要素を、末尾から前方検索し、存在すればそのインデックスを、存在しなければ-1を返します。
int lastIndexOf<Type>( WrappedList<Type> &list, Type element, int from )
指定された要素を、指定インデックスの位置から後方検索し、存在すればそのインデックスを、存在しなければ-1を返します。
void reverse<Type>( WrappedList<Type> &list )
リストが保持する全要素の順序を反転させます。
DataWrapper<Type>[ ] toDataWrapperArray<Type>( WrappedList<Type> &list )
リストが保持する全要素を、DataWrapper配列に格納して返します。

構造体 - Structs

文法的定義
- Signature
struct WrappedList<Type>
構造体名
- Name
WrappedList<Type>
役割
- Role
リスト構造体です。リストのデータを保持します。

変数 - Variables

- なし - None -


関数 - Functions

文法的定義
- Signature
void clear<Type>( WrappedList<Type> &list )
関数名
- Name
clear<Type>
役割
- Role
要素を全て削除します。
引数
- Arguments
(WrappedList<Type>型) list : 対象のリスト構造体
戻り値
- Return
(void型)
文法的定義
- Signature
int size<Type>( WrappedList<Type> &list )
関数名
- Name
size<Type>
役割
- Role
使用中のサイズを返します。
引数
- Arguments
(WrappedList<Type>型) list : 対象のリスト構造体
戻り値
- Return
(int型)
文法的定義
- Signature
void add<Type>( WrappedList<Type> &list, Type value )
関数名
- Name
add<Type>
役割
- Role
リストの末尾に要素を追加します。
引数
- Arguments
(WrappedList<Type>型) list : 対象のリスト構造体
(Type型) value : 追加する要素
戻り値
- Return
(void型)
文法的定義
- Signature
Type get<Type>( WrappedList<Type> &list, int index )
関数名
- Name
get<Type>
役割
- Role
特定インデックスの要素を取得します。
引数
- Arguments
(WrappedList<Type>型) list : 対象のリスト構造体
(int型) index : 取得したい要素のインデックス
戻り値
- Return
(Type型) 指定されたインデックスの要素
文法的定義
- Signature
void set<Type>( WrappedList<Type> &list, int index, Type element )
関数名
- Name
set<Type>
役割
- Role
特定インデックスの要素を代入します。そのインデックスの位置にあった要素は上書きされます。
引数
- Arguments
(WrappedList<Type>型) list : 対象のリスト構造体
(int型) index : 代入したい要素のインデックス
(Type型) element : 代入する要素
戻り値
- Return
(void型)
文法的定義
- Signature
Type insert<Type>( WrappedList<Type> &list, int index, Type value )
関数名
- Name
insert<Type>
役割
- Role
特定インデックスに要素を挿入します。そのインデックスの位置にあった要素は、次のインデックスの位置に移動します。また、それ以降の全ての要素も、インデックスが後方に 1 ずつ移動します。
引数
- Arguments
(WrappedList<Type>型) list : 対象のリスト構造体
(int型) index : 挿入したい要素のインデックス
element : 挿入する要素
戻り値
- Return
(Type型)
文法的定義
- Signature
bool contains<Type>( WrappedList<Type> &list, Type element )
関数名
- Name
contains<Type>
役割
- Role
リストが指定された要素を含んでいるか判定します。
引数
- Arguments
(WrappedList<Type>型) list : 対象のリスト構造体
(Type型) element : 含まれるか判定したい要素
戻り値
- Return
(bool型)
文法的定義
- Signature
Type removeAt<Type>( WrappedList<Type> &list, int index )
関数名
- Name
removeAt<Type>
役割
- Role
特定インデックスの要素を削除します。
引数
- Arguments
(WrappedList<Type>型) list : 対象のリスト構造体
(int型) index : 削除したい要素のインデックス
戻り値
- Return
(Type型)
文法的定義
- Signature
void remove<Type>( WrappedList<Type> &list, Type element )
関数名
- Name
remove<Type>
役割
- Role
指定された要素を削除します。複数存在する場合は、最初のものだけが削除されます。
引数
- Arguments
(WrappedList<Type>型) list : 対象のリスト構造体
(Type型) element : 削除したい要素
戻り値
- Return
(void型)
文法的定義
- Signature
void removeAll<Type>( WrappedList<Type> &list, Type element )
関数名
- Name
removeAll<Type>
役割
- Role
指定された要素を全て削除します。
引数
- Arguments
(WrappedList<Type>型) list : 対象のリスト構造体
(Type型) element : 削除したい要素
戻り値
- Return
(void型)
文法的定義
- Signature
int indexOf<Type>( WrappedList<Type> &list, Type element )
関数名
- Name
indexOf<Type>
役割
- Role
指定された要素を、先頭から後方検索し、存在すればそのインデックスを、存在しなければ-1を返します。
引数
- Arguments
(WrappedList<Type>型) list : 対象のリスト構造体
(Type型) element : 検索したい要素
戻り値
- Return
(int型)
文法的定義
- Signature
int indexOf<Type>( WrappedList<Type> &list, Type element, int from )
関数名
- Name
indexOf<Type>
役割
- Role
指定された要素を、指定インデックスの位置から後方検索し、存在すればそのインデックスを、存在しなければ-1を返します。
引数
- Arguments
(WrappedList<Type>型) list : 対象のリスト構造体
(Type型) element : 削除したい要素
(int型) from : 検索開始インデックス
戻り値
- Return
(int型)
文法的定義
- Signature
int lastIndexOf<Type>( WrappedList<Type> &list, Type element )
関数名
- Name
lastIndexOf<Type>
役割
- Role
指定された要素を、末尾から前方検索し、存在すればそのインデックスを、存在しなければ-1を返します。
引数
- Arguments
(WrappedList<Type>型) list : 対象のリスト構造体
(Type型) element : 削除したい要素
戻り値
- Return
(int型)
文法的定義
- Signature
int lastIndexOf<Type>( WrappedList<Type> &list, Type element, int from )
関数名
- Name
lastIndexOf<Type>
役割
- Role
指定された要素を、指定インデックスの位置から後方検索し、存在すればそのインデックスを、存在しなければ-1を返します。
引数
- Arguments
(WrappedList<Type>型) list : 対象のリスト構造体
(Type型) element : 削除したい要素
(int型) from : 検索開始インデックス
戻り値
- Return
(int型)
文法的定義
- Signature
void reverse<Type>( WrappedList<Type> &list )
関数名
- Name
reverse<Type>
役割
- Role
リストが保持する全要素の順序を反転させます。
引数
- Arguments
(WrappedList<Type>型) list : 対象のリスト構造体
戻り値
- Return
(void型)
文法的定義
- Signature
DataWrapper<Type>[ ] toDataWrapperArray<Type>( WrappedList<Type> &list )
関数名
- Name
toDataWrapperArray<Type>
役割
- Role
リストが保持する全要素を、DataWrapper配列に格納して返します。
引数
- Arguments
(WrappedList<Type>型) list : 対象のリスト構造体
戻り値
- Return
(DataWrapper<Type>[]型) リストの全要素をまとめたDataWrapper配列