関数orderWinData マニュアル

(The documentation of function orderWinData)

Last Update: 2025/6/11


◆機能・用途(Purpose)

WINの秒ブロックを時刻順に並べ替え、欠損がある場合はダミーデータを挿入して連続データにする。
Sort second blocks of a WIN data to the order of time, and insert dammy data for defects to make the entire data continuous.


◆形式(Format)

#include <win/convert.h>
inline struct win_secondBlock ∗orderWinData
(const int NsecondBlock_before,int ∗NsecondBlock_after,
 struct win_secondBlock ∗original)


◆引数(Arguments)

NsecondBlock_before 並べ替える前の秒ブロックの個数。 関数win_countSecondBlock の戻り値を与える。
The number of second blocks before sorting, obtained by function win_countSecondBlock.
NsecondBlock_after 並べ替えた後の秒ブロックの個数の代入先。 宣言しただけのint型変数に&を付けて与える。 関数内で値が設定される。 なお、この値は欠損の補間のために挿入されるダミーの秒ブロックを含む。
Memory into which the number of second blocks after sorting is to be inserted. Give an empty int-type variable with &. Within the function, the value is set, which includes dummy second blocks for the interpolation of data defects.
original 並べ替える前の秒ブロックのデータから成る配列。 関数read_win_fileの戻り値を 関数sortWinData を用いて整形したものを与える。
An array composed of the data of second blocks before sorting, obtained by functions read_win_file and sortWinData.


◆戻り値(Return value)

引数originalが表す秒ブロックのデータを時刻順に並べ替え、欠損を補間したデータを表す配列。 戻り値の仕様は以下の通りである。
An array that represents data of second blocks, sorted in the order of time from the data given by argument original with the data defects being interpolated. The specification of the return value is as follows.


◆使用例(Example)

int NsecondBlock_before =win_countSecondBlock("data.win");

struct win_data winData_before =read_win_file("data.win");

struct win_channelCodeList channels =win_readChannelCode("channel_codes.txt");

struct win_channelTable channelTable_all =win_readChannelTable("channels.tbl");

struct win_channelTable channelTable_use =win_selectChannelTable(channelTable_all,channels);

sortWinData (NsecondBlock_before, winData_before, channelTable_use);

int NsecondBlock_before_after;

struct win_secondBlock winData_after =orderWinData (NsecondBlock_before, &NsecondBlock_after, winData_before);


◆使用上の注意(Note)

上記の通り、メンバchannelBlockに関しては新たに配列を作成するのではなく 元々の配列の先頭アドレスがコピーされるだけである。 したがって この関数の実行後に引数originalの配列要素のメンバchannelBlockの動的メモリを 解放してはならない。 解放するとこの関数の戻り値からもデータが失われてしまう。 例えば上記「使用例」の後に以下の処理を行ってはならない。
As mentioned above, for the member channelBlock, new array is not created but the first address of the original array is simply copied. Therefore, make sure NOT to release the dynamic memories for the member channelBlock of the array components of argument original after calling this function. For example, the processings shown below must NOT be conducted after the “Example” shown above.

for(n=0;n<NsecondBlock_before;n++){
     free(winData_before[n].channelBlock);
}