next up previous contents
Next: RemoveColumn Up: Column methods Previous: ClearColumn

DeleteColumn

NAME DeleteColumn

PROTOTYPE

#include "SSTable.h"
int SSTable::DeleteColumn(int colIndex);

EXAMPLE

#include "SSTable.h"
...
SSTable * pTable = new SSTable();
ReVarCifArray<CifString> last_column;
CifString cs;

while (tokenizer.hasMoreTokens()) {
  cs = (char *) tokenizer.GetNextToken();
  last_column.Add(cs);
  cs.Clear();
}

pTable->InsertColumn(last_column, "LastColumn",
  pTable->GetNumColumns(), TRUE);

// process the last column
processTableColumn(*pTable, pTable->GetColumnIndex(
  "LastColumn"));

// erase the last column
pTable->DeleteColumn(pTable->GetColumnIndex("LastColumn"));

last_column.Clear(); // clean up array and restock with new data
while (tokenizer2.hasMoreTokens()) {
  cs = (char *) tokenizer2.GetNextToken();
  last_column.Add(cs);
  cs.Clear();
}

// fill the column again and reprocess it, since DeleteColumn
// keeps the column there (any column filler can be used here)
pTable->FillColumn(last_column, pTable->GetColumnIndex(
  "LastColumn"));
processTableColumn(*pTable, pTable->GetColumnIndex(
  "LastColumn"));
PURPOSE

DeleteColumn will remove the data from a column, but not the column itself. This method is safer to use than ClearColumn unless the peculiar behavior of ClearColumn is desired.

RECEIVES

colIndex The index of the column to be deleted.

RETURN VALUE

A negative value indicates an error or warning.

REMARKS

Using DeleteColumn ensures that filling or appending data to a column results in proper row-wise positioning. For example, if a 10 element column is erased with ClearColumn and then AppendElementToColumn is called, the element will be added to the 11th position with 10 ``blank'' placeholders ahead of it. If DeleteColumn is used, then there will only be 1 element in the column.

See also: ClearColumn
  RemoveColumn



Olivera Tosic
12/17/1999