SNAP Library 4.0, Developer Reference  2017-07-27 13:18:06
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
attr.h
Go to the documentation of this file.
3 
4 class TAttr {
5 private:
6  // Sparse Attributes Name Mapping
9 
13 private:
14  int GetIdVSAttr(const TInt& AttrId, const TAttrType Type, TIntV& IdV) const;
15 public:
17  FltAttrVals(), StrAttrVals() { }
18  TAttr(const TAttr& Attrs) : AttrNameToId(Attrs.AttrNameToId),
22  TAttr(TSIn& SIn) : AttrNameToId(SIn), AttrIdToName(SIn),
23  IntAttrVals(SIn), FltAttrVals(SIn), StrAttrVals(SIn) { }
25  void Load(TSIn& SIn) {
26  AttrNameToId.Load(SIn);
27  AttrIdToName.Load(SIn);
28  IntAttrVals.Load(SIn);
29  FltAttrVals.Load(SIn);
30  StrAttrVals.Load(SIn);
31  }
33  void Save(TSOut& SOut) const {
34  AttrNameToId.Save(SOut); AttrIdToName.Save(SOut);
35  IntAttrVals.Save(SOut); FltAttrVals.Save(SOut); StrAttrVals.Save(SOut); }
38 
41 
43  int AddSAttrDat(const TInt& Id, const TStr& AttrName, const TInt& Val);
45  int AddSAttrDat(const TInt& Id, const TInt& AttrId, const TInt& Val);
46 
48  int AddSAttrDat(const TInt& Id, const TStr& AttrName, const TFlt& Val);
50  int AddSAttrDat(const TInt& Id, const TInt& AttrId, const TFlt& Val);
51 
53  int AddSAttrDat(const TInt& Id, const TStr& AttrName, const TStr& Val);
55  int AddSAttrDat(const TInt& Id, const TInt& AttrId, const TStr& Val);
56 
58  int GetSAttrDat(const TInt& Id, const TStr& AttrName, TInt& ValX) const;
60  int GetSAttrDat(const TInt& Id, const TInt& AttrId, TInt& ValX) const;
61 
63  int GetSAttrDat(const TInt& Id, const TStr& AttrName, TFlt& ValX) const;
65  int GetSAttrDat(const TInt& Id, const TInt& AttrId, TFlt& ValX) const;
66 
68  int GetSAttrDat(const TInt& Id, const TStr& AttrName, TStr& ValX) const;
70  int GetSAttrDat(const TInt& Id, const TInt& AttrId, TStr& ValX) const;
71 
73  int DelSAttrDat(const TInt& Id, const TStr& AttrName);
75  int DelSAttrDat(const TInt& Id, const TInt& AttrId);
76 
78  void DelSAttrId(const TInt& Id);
79 
81  void GetSAttrV(const TInt& Id, const TAttrType AttrType, TAttrPrV& AttrV) const;
82 
84  int GetIdVSAttr(const TStr& AttrName, TIntV& IdV) const;
86  int GetIdVSAttr(const TInt& AttrId, TIntV& IdV) const;
87 
89  int AddSAttr(const TStr& Name, const TAttrType& AttrType, TInt& AttrIdX);
90 
92  int GetSAttrId(const TStr& Name, TInt& AttrIdX, TAttrType& AttrTypeX) const;
94  int GetSAttrName(const TInt& AttrId, TStr& NameX, TAttrType& AttrTypeX) const;
95 };
96 
97 
98 class TAttrPair {
99 private:
102 
106 private:
107  int GetIdVSAttr(const TInt& AttrId, const TAttrType Type, TIntPrV& IdV) const;
108 public:
110  FltAttrVals(), StrAttrVals() { }
116  IntAttrVals(SIn), FltAttrVals(SIn), StrAttrVals(SIn) { }
118  void Save(TSOut& SOut) const {
119  AttrNameToId.Save(SOut); AttrIdToName.Save(SOut);
120  IntAttrVals.Save(SOut); FltAttrVals.Save(SOut); StrAttrVals.Save(SOut); }
123 
125  int AddSAttrDat(const TIntPr& Id, const TStr& AttrName, const TInt& Val);
127  int AddSAttrDat(const TIntPr& Id, const TInt& AttrId, const TInt& Val);
128 
130  int AddSAttrDat(const TIntPr& Id, const TStr& AttrName, const TFlt& Val);
132  int AddSAttrDat(const TIntPr& Id, const TInt& AttrId, const TFlt& Val);
133 
135  int AddSAttrDat(const TIntPr& Id, const TStr& AttrName, const TStr& Val);
137  int AddSAttrDat(const TIntPr& Id, const TInt& AttrId, const TStr& Val);
138 
140  int GetSAttrDat(const TIntPr& Id, const TStr& AttrName, TInt& ValX) const;
142  int GetSAttrDat(const TIntPr& Id, const TInt& AttrId, TInt& ValX) const;
143 
145  int GetSAttrDat(const TIntPr& Id, const TStr& AttrName, TFlt& ValX) const;
147  int GetSAttrDat(const TIntPr& Id, const TInt& AttrId, TFlt& ValX) const;
148 
150  int GetSAttrDat(const TIntPr& Id, const TStr& AttrName, TStr& ValX) const;
152  int GetSAttrDat(const TIntPr& Id, const TInt& AttrId, TStr& ValX) const;
153 
155  int DelSAttrDat(const TIntPr& Id, const TStr& AttrName);
157  int DelSAttrDat(const TIntPr& Id, const TInt& AttrId);
158 
160  void DelSAttrId(const TIntPr& Id);
161 
163  void GetSAttrV(const TIntPr& Id, const TAttrType AttrType, TAttrPrV& AttrV) const;
164 
166  int GetIdVSAttr(const TStr& AttrName, TIntPrV& IdV) const;
168  int GetIdVSAttr(const TInt& AttrId, TIntPrV& IdV) const;
169 
171  int AddSAttr(const TStr& Name, const TAttrType& AttrType, TInt& AttrIdX);
172 
174  int GetSAttrId(const TStr& Name, TInt& AttrIdX, TAttrType& AttrTypeX) const;
176  int GetSAttrName(const TInt& AttrId, TStr& NameX, TAttrType& AttrTypeX) const;
177 };
int DelSAttrDat(const TInt &Id, const TStr &AttrName)
Delete attribute with name AttrName for the given id Id.
Definition: attr.cpp:103
int GetSAttrDat(const TIntPr &Id, const TStr &AttrName, TInt &ValX) const
Get Int attribute with name AttrName for the given id Id.
Definition: attr.cpp:298
TAttrPair()
Definition: attr.h:109
enum TAttrType_ TAttrType
Types for tables, sparse and dense attributes.
Definition: attr.h:98
int AddSAttrDat(const TInt &Id, const TStr &AttrName, const TInt &Val)
Add Int attribute with name AttrName for the given id Id.
Definition: attr.cpp:2
void DelSAttrId(const TIntPr &Id)
Delete all attributes for the given id Id.
Definition: attr.cpp:368
int GetSAttrName(const TInt &AttrId, TStr &NameX, TAttrType &AttrTypeX) const
Given the attribute id AttrId, get the attribute name.
Definition: attr.cpp:233
void Save(TSOut &SOut) const
Definition: hash.h:183
TIntIntStrPrH AttrIdToName
Definition: attr.h:101
int GetSAttrName(const TInt &AttrId, TStr &NameX, TAttrType &AttrTypeX) const
Given the attribute id AttrId, get the attribute name and type.
Definition: attr.cpp:477
void DelSAttrId(const TInt &Id)
Delete all attributes for the given id Id.
Definition: attr.cpp:124
void Load(TSIn &SIn)
Definition: hash.h:177
Definition: dt.h:1383
Definition: fl.h:58
TAttr(const TAttr &Attrs)
Definition: attr.h:18
TIntIntPrPrIntH IntAttrVals
Definition: attr.h:103
Definition: attr.h:4
TAttrPair(TSIn &SIn)
Constructor for loading attributes from a (binary) stream SIn.
Definition: attr.h:115
void Save(TSOut &SOut) const
Saves the attributes to a (binary) stream SOut.
Definition: attr.h:118
size_t GetMemUsed() const
Returns the amount of memory used by sparse attributes.
Definition: attr.h:40
TIntIntStrPrH AttrIdToName
Definition: attr.h:8
::TSize GetMemUsed() const
Definition: hash.h:201
int GetIdVSAttr(const TInt &AttrId, const TAttrType Type, TIntV &IdV) const
Definition: attr.cpp:167
TPair< TStr, TAttrType > TAttrPr
Definition: attr.h:1
TIntIntPrPrFltH FltAttrVals
Definition: attr.h:104
TStrIntPrH AttrNameToId
Definition: attr.h:100
Definition: fl.h:128
void GetSAttrV(const TInt &Id, const TAttrType AttrType, TAttrPrV &AttrV) const
Get a list of all attributes of type AttrType for the given id Id.
Definition: attr.cpp:139
TIntIntPrPrStrH StrAttrVals
Definition: attr.h:105
TAttr()
Definition: attr.h:16
Definition: dt.h:1134
int GetSAttrId(const TStr &Name, TInt &AttrIdX, TAttrType &AttrTypeX) const
Given the attribute name Name, get the attribute id and type.
Definition: attr.cpp:467
TIntPrStrH StrAttrVals
Definition: attr.h:12
int GetIdVSAttr(const TInt &AttrId, const TAttrType Type, TIntPrV &IdV) const
Definition: attr.cpp:411
int GetSAttrDat(const TInt &Id, const TStr &AttrName, TInt &ValX) const
Get Int attribute with name AttrName for the given id Id.
Definition: attr.cpp:54
int AddSAttr(const TStr &Name, const TAttrType &AttrType, TInt &AttrIdX)
Adds a mapping for an attribute with name Name and type AttrType.
Definition: attr.cpp:454
TVec< TAttrPr > TAttrPrV
Definition: attr.h:2
void Clr()
Clears the contents of the attribute map.
Definition: attr.h:122
int AddSAttrDat(const TIntPr &Id, const TStr &AttrName, const TInt &Val)
Add Int attribute with name AttrName for the given id Id.
Definition: attr.cpp:246
Definition: dt.h:412
void Save(TSOut &SOut) const
Saves the attributes to a (binary) stream SOut.
Definition: attr.h:33
int DelSAttrDat(const TIntPr &Id, const TStr &AttrName)
Delete attribute with name AttrName for the given id Id.
Definition: attr.cpp:347
void GetSAttrV(const TIntPr &Id, const TAttrType AttrType, TAttrPrV &AttrV) const
Get a list of all attributes of the given type AttrType for the given id Id.
Definition: attr.cpp:383
TIntPrFltH FltAttrVals
Definition: attr.h:11
void Clr(const bool &DoDel=true, const int &NoDelLim=-1, const bool &ResetDat=true)
Definition: hash.h:361
int GetSAttrId(const TStr &Name, TInt &AttrIdX, TAttrType &AttrTypeX) const
Given the attribute name Name, get the attribute id.
Definition: attr.cpp:224
void Load(TSIn &SIn)
Load attribute from input stream.
Definition: attr.h:25
TIntPrIntH IntAttrVals
Definition: attr.h:10
TAttrPair(const TAttrPair &Attrs)
Definition: attr.h:111
TAttr(TSIn &SIn)
Constructor for loading attributes from a (binary) stream SIn.
Definition: attr.h:22
void Clr()
Clears the contents of the attribute map.
Definition: attr.h:37
int AddSAttr(const TStr &Name, const TAttrType &AttrType, TInt &AttrIdX)
Adds a mapping for an attribute with name Name and type AttrType.
Definition: attr.cpp:210
Vector is a sequence TVal objects representing an array that can change in size.
Definition: ds.h:430
TStrIntPrH AttrNameToId
Definition: attr.h:7