SNAP Library 3.0, User Reference  2016-07-20 17:56:49
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TRowIteratorWithRemove Class Reference

Iterator class for TTable rows, that allows logical row removal while iterating. More...

#include <table.h>

Public Member Functions

 TRowIteratorWithRemove ()
 Default constructor. More...
 
 TRowIteratorWithRemove (TInt RowIdx, TTable *TablePtr)
 Constructs iterator pointing to given row. More...
 
 TRowIteratorWithRemove (TInt RowIdx, TTable *TablePtr, TBool IsStart)
 Constructs iterator pointing to given row. More...
 
 TRowIteratorWithRemove (const TRowIteratorWithRemove &RowI)
 Copy constructor. More...
 
TRowIteratorWithRemoveoperator++ (int)
 Increments the iterator. More...
 
TRowIteratorWithRemoveNext ()
 Increments the iterator (For Python compatibility). More...
 
bool operator< (const TRowIteratorWithRemove &RowI) const
 Checks if this iterator points to a row that is before the one pointed by RowI. More...
 
bool operator== (const TRowIteratorWithRemove &RowI) const
 Checks if this iterator points to the same row pointed by RowI. More...
 
TInt GetRowIdx () const
 Gets physical index of current row. More...
 
TInt GetNextRowIdx () const
 Gets physical index of next row. More...
 
TInt GetNextIntAttr (TInt ColIdx) const
 Returns value of integer attribute specified by integer column index for next row. More...
 
TFlt GetNextFltAttr (TInt ColIdx) const
 Returns value of float attribute specified by float column index for next row. More...
 
TStr GetNextStrAttr (TInt ColIdx) const
 Returns value of string attribute specified by string column index for next row. More...
 
TInt GetNextIntAttr (const TStr &Col) const
 Returns value of integer attribute specified by attribute name for next row. More...
 
TFlt GetNextFltAttr (const TStr &Col) const
 Returns value of float attribute specified by attribute name for next row. More...
 
TStr GetNextStrAttr (const TStr &Col) const
 Returns value of string attribute specified by attribute name for next row. More...
 
TBool IsFirst () const
 Checks whether iterator points to first valid row of the table. More...
 
void RemoveNext ()
 Removes next row. More...
 
TBool CompareAtomicConst (TInt ColIdx, const TPrimitive &Val, TPredComp Cmp)
 Compares value in column ColIdx with given primitive Val. More...
 

Private Attributes

TInt CurrRowIdx
 Physical row index of current row pointer by iterator. More...
 
TTableTable
 Reference to table containing this row. More...
 
TBool Start
 A flag indicating whether the current row in the first valid row of the table. More...
 

Detailed Description

Iterator class for TTable rows, that allows logical row removal while iterating.

Definition at line 383 of file table.h.

Constructor & Destructor Documentation

TRowIteratorWithRemove::TRowIteratorWithRemove ( )
inline

Default constructor.

Definition at line 389 of file table.h.

389 : CurrRowIdx(0), Table(NULL), Start(true) {}
TBool Start
A flag indicating whether the current row in the first valid row of the table.
Definition: table.h:386
TTable * Table
Reference to table containing this row.
Definition: table.h:385
TInt CurrRowIdx
Physical row index of current row pointer by iterator.
Definition: table.h:384
TRowIteratorWithRemove::TRowIteratorWithRemove ( TInt  RowIdx,
TTable TablePtr 
)

Constructs iterator pointing to given row.

Definition at line 215 of file table.cpp.

215  :
216  CurrRowIdx(RowIdx), Table(TablePtr), Start(RowIdx == TablePtr->FirstValidRow) {}
TInt FirstValidRow
Physical index of first valid row.
Definition: table.h:563
TBool Start
A flag indicating whether the current row in the first valid row of the table.
Definition: table.h:386
TTable * Table
Reference to table containing this row.
Definition: table.h:385
TInt CurrRowIdx
Physical row index of current row pointer by iterator.
Definition: table.h:384
TRowIteratorWithRemove::TRowIteratorWithRemove ( TInt  RowIdx,
TTable TablePtr,
TBool  IsStart 
)
inline

Constructs iterator pointing to given row.

Definition at line 393 of file table.h.

393  : CurrRowIdx(RowIdx),
394  Table(TablePtr), Start(IsStart) {}
TBool Start
A flag indicating whether the current row in the first valid row of the table.
Definition: table.h:386
TTable * Table
Reference to table containing this row.
Definition: table.h:385
TInt CurrRowIdx
Physical row index of current row pointer by iterator.
Definition: table.h:384
TRowIteratorWithRemove::TRowIteratorWithRemove ( const TRowIteratorWithRemove RowI)
inline

Copy constructor.

Definition at line 396 of file table.h.

396  : CurrRowIdx(RowI.CurrRowIdx),
397  Table(RowI.Table), Start(RowI.Start) {}
TBool Start
A flag indicating whether the current row in the first valid row of the table.
Definition: table.h:386
TTable * Table
Reference to table containing this row.
Definition: table.h:385
TInt CurrRowIdx
Physical row index of current row pointer by iterator.
Definition: table.h:384

Member Function Documentation

TBool TRowIteratorWithRemove::CompareAtomicConst ( TInt  ColIdx,
const TPrimitive Val,
TPredComp  Cmp 
)

Compares value in column ColIdx with given primitive Val.

Definition at line 282 of file table.cpp.

282  {
283  TBool Result;
284  switch (Val.GetType()) {
285  case atInt:
286  Result = TPredicate::EvalAtom(GetNextIntAttr(ColIdx), Val.GetInt(), Cmp);
287  break;
288  case atFlt:
289  Result = TPredicate::EvalAtom(GetNextFltAttr(ColIdx), Val.GetFlt(), Cmp);
290  break;
291  case atStr:
292  Result = TPredicate::EvalStrAtom(GetNextStrAttr(ColIdx), Val.GetStr(), Cmp);
293  break;
294  default:
295  Result = TBool(false);
296  }
297  return Result;
298 }
TFlt GetNextFltAttr(TInt ColIdx) const
Returns value of float attribute specified by float column index for next row.
Definition: table.cpp:252
TStr GetNextStrAttr(TInt ColIdx) const
Returns value of string attribute specified by string column index for next row.
Definition: table.cpp:256
static TBool EvalStrAtom(const TStr &Val1, const TStr &Val2, TPredComp Cmp)
Compare atomic string values Val1 and Val2 using predicate Cmp.
Definition: table.h:123
Definition: gbase.h:23
TStr GetStr() const
Definition: table.h:237
TInt GetInt() const
Definition: table.h:235
TAttrType GetType() const
Definition: table.h:238
Definition: gbase.h:23
static TBool EvalAtom(T Val1, T Val2, TPredComp Cmp)
Compare atomic values Val1 and Val2 using predicate Cmp.
Definition: table.h:110
bool Cmp(const int &RelOp, const TRec &Rec1, const TRec &Rec2)
Definition: bd.h:426
Definition: gbase.h:23
TInt GetNextIntAttr(TInt ColIdx) const
Returns value of integer attribute specified by integer column index for next row.
Definition: table.cpp:248
Definition: dt.h:881
TFlt GetFlt() const
Definition: table.h:236
TFlt TRowIteratorWithRemove::GetNextFltAttr ( TInt  ColIdx) const

Returns value of float attribute specified by float column index for next row.

Definition at line 252 of file table.cpp.

252  {
253  return Table->FltCols[ColIdx][GetNextRowIdx()];
254 }
TInt GetNextRowIdx() const
Gets physical index of next row.
Definition: table.cpp:243
TVec< TFltV > FltCols
Data columns of floating point attributes.
Definition: table.h:569
TTable * Table
Reference to table containing this row.
Definition: table.h:385
TFlt TRowIteratorWithRemove::GetNextFltAttr ( const TStr Col) const

Returns value of float attribute specified by attribute name for next row.

Definition at line 265 of file table.cpp.

265  {
266  TInt ColIdx = Table->GetColIdx(Col);
267  return Table->FltCols[ColIdx][GetNextRowIdx()];
268 }
TInt GetColIdx(const TStr &ColName) const
Gets index of column ColName among columns of the same type in the schema.
Definition: table.h:1004
TInt GetNextRowIdx() const
Gets physical index of next row.
Definition: table.cpp:243
Definition: dt.h:1044
TVec< TFltV > FltCols
Data columns of floating point attributes.
Definition: table.h:569
TTable * Table
Reference to table containing this row.
Definition: table.h:385
TInt TRowIteratorWithRemove::GetNextIntAttr ( TInt  ColIdx) const

Returns value of integer attribute specified by integer column index for next row.

Definition at line 248 of file table.cpp.

248  {
249  return Table->IntCols[ColIdx][GetNextRowIdx()];
250 }
TVec< TIntV > IntCols
Next[i] is the successor of row i. Table iterators follow the order dictated by Next ...
Definition: table.h:568
TInt GetNextRowIdx() const
Gets physical index of next row.
Definition: table.cpp:243
TTable * Table
Reference to table containing this row.
Definition: table.h:385
TInt TRowIteratorWithRemove::GetNextIntAttr ( const TStr Col) const

Returns value of integer attribute specified by attribute name for next row.

Definition at line 260 of file table.cpp.

260  {
261  TInt ColIdx = Table->GetColIdx(Col);
262  return Table->IntCols[ColIdx][GetNextRowIdx()];
263 }
TInt GetColIdx(const TStr &ColName) const
Gets index of column ColName among columns of the same type in the schema.
Definition: table.h:1004
TVec< TIntV > IntCols
Next[i] is the successor of row i. Table iterators follow the order dictated by Next ...
Definition: table.h:568
TInt GetNextRowIdx() const
Gets physical index of next row.
Definition: table.cpp:243
Definition: dt.h:1044
TTable * Table
Reference to table containing this row.
Definition: table.h:385
TInt TRowIteratorWithRemove::GetNextRowIdx ( ) const

Gets physical index of next row.

Definition at line 243 of file table.cpp.

243  {
244  return (Start ? Table->FirstValidRow : Table->Next[CurrRowIdx]);
245 }
TInt FirstValidRow
Physical index of first valid row.
Definition: table.h:563
TBool Start
A flag indicating whether the current row in the first valid row of the table.
Definition: table.h:386
TIntV Next
A vector describing the logical order of the rows.
Definition: table.h:565
TTable * Table
Reference to table containing this row.
Definition: table.h:385
TInt CurrRowIdx
Physical row index of current row pointer by iterator.
Definition: table.h:384
TStr TRowIteratorWithRemove::GetNextStrAttr ( TInt  ColIdx) const

Returns value of string attribute specified by string column index for next row.

Definition at line 256 of file table.cpp.

256  {
257  return Table->GetStrVal(ColIdx, GetNextRowIdx());
258 }
TInt GetNextRowIdx() const
Gets physical index of next row.
Definition: table.cpp:243
TTable * Table
Reference to table containing this row.
Definition: table.h:385
TStr GetStrVal(TInt ColIdx, TInt RowIdx) const
Gets the value in column with id ColIdx at row RowIdx.
Definition: table.h:636
TStr TRowIteratorWithRemove::GetNextStrAttr ( const TStr Col) const

Returns value of string attribute specified by attribute name for next row.

Definition at line 270 of file table.cpp.

270  {
271  return Table->GetStrVal(Col, GetNextRowIdx());
272 }
TInt GetNextRowIdx() const
Gets physical index of next row.
Definition: table.cpp:243
TTable * Table
Reference to table containing this row.
Definition: table.h:385
TStr GetStrVal(TInt ColIdx, TInt RowIdx) const
Gets the value in column with id ColIdx at row RowIdx.
Definition: table.h:636
TInt TRowIteratorWithRemove::GetRowIdx ( ) const

Gets physical index of current row.

Definition at line 239 of file table.cpp.

239  {
240  return CurrRowIdx;
241 }
TInt CurrRowIdx
Physical row index of current row pointer by iterator.
Definition: table.h:384
TBool TRowIteratorWithRemove::IsFirst ( ) const

Checks whether iterator points to first valid row of the table.

Definition at line 274 of file table.cpp.

274  {
275  return CurrRowIdx == Table->FirstValidRow;
276 }
TInt FirstValidRow
Physical index of first valid row.
Definition: table.h:563
TTable * Table
Reference to table containing this row.
Definition: table.h:385
TInt CurrRowIdx
Physical row index of current row pointer by iterator.
Definition: table.h:384
TRowIteratorWithRemove & TRowIteratorWithRemove::Next ( )

Increments the iterator (For Python compatibility).

Definition at line 222 of file table.cpp.

222  {
224  Start = false;
226  return *this;
227 }
TBool Start
A flag indicating whether the current row in the first valid row of the table.
Definition: table.h:386
TInt GetNextRowIdx() const
Gets physical index of next row.
Definition: table.cpp:243
#define Assert(Cond)
Definition: bd.h:251
static const TInt Invalid
Special value for Next vector entry - logically removed row.
Definition: table.h:498
TInt CurrRowIdx
Physical row index of current row pointer by iterator.
Definition: table.h:384
TRowIteratorWithRemove & TRowIteratorWithRemove::operator++ ( int  )

Increments the iterator.

Definition at line 218 of file table.cpp.

218  {
219  return this->Next();
220 }
TRowIteratorWithRemove & Next()
Increments the iterator (For Python compatibility).
Definition: table.cpp:222
bool TRowIteratorWithRemove::operator< ( const TRowIteratorWithRemove RowI) const

Checks if this iterator points to a row that is before the one pointed by RowI.

Definition at line 229 of file table.cpp.

229  {
230  if (CurrRowIdx == TTable::Last) { return false; }
231  if (RowI.CurrRowIdx == TTable::Last) { return true; }
232  return CurrRowIdx < RowI.CurrRowIdx;
233 }
static const TInt Last
Special value for Next vector entry - last row in table.
Definition: table.h:497
TInt CurrRowIdx
Physical row index of current row pointer by iterator.
Definition: table.h:384
bool TRowIteratorWithRemove::operator== ( const TRowIteratorWithRemove RowI) const

Checks if this iterator points to the same row pointed by RowI.

Definition at line 235 of file table.cpp.

235  {
236  return CurrRowIdx == RowI.CurrRowIdx;
237 }
TInt CurrRowIdx
Physical row index of current row pointer by iterator.
Definition: table.h:384
void TRowIteratorWithRemove::RemoveNext ( )

Removes next row.

Definition at line 278 of file table.cpp.

278  {
280 }
void RemoveRow(TInt RowIdx, TInt PrevRowIdx)
Removes row with id RowIdx.
Definition: table.cpp:1115
TInt GetNextRowIdx() const
Gets physical index of next row.
Definition: table.cpp:243
TTable * Table
Reference to table containing this row.
Definition: table.h:385
TInt CurrRowIdx
Physical row index of current row pointer by iterator.
Definition: table.h:384

Member Data Documentation

TInt TRowIteratorWithRemove::CurrRowIdx
private

Physical row index of current row pointer by iterator.

Definition at line 384 of file table.h.

TBool TRowIteratorWithRemove::Start
private

A flag indicating whether the current row in the first valid row of the table.

Definition at line 386 of file table.h.

TTable* TRowIteratorWithRemove::Table
private

Reference to table containing this row.

Definition at line 385 of file table.h.


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