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
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 Save(TSOut& SOut) const {
26  AttrNameToId.Save(SOut); AttrIdToName.Save(SOut);
27  IntAttrVals.Save(SOut); FltAttrVals.Save(SOut); StrAttrVals.Save(SOut); }
30 
33 
35  int AddSAttrDat(const TInt& Id, const TStr& AttrName, const TInt& Val);
37  int AddSAttrDat(const TInt& Id, const TInt& AttrId, const TInt& Val);
38 
40  int AddSAttrDat(const TInt& Id, const TStr& AttrName, const TFlt& Val);
42  int AddSAttrDat(const TInt& Id, const TInt& AttrId, const TFlt& Val);
43 
45  int AddSAttrDat(const TInt& Id, const TStr& AttrName, const TStr& Val);
47  int AddSAttrDat(const TInt& Id, const TInt& AttrId, const TStr& Val);
48 
50  int GetSAttrDat(const TInt& Id, const TStr& AttrName, TInt& ValX) const;
52  int GetSAttrDat(const TInt& Id, const TInt& AttrId, TInt& ValX) const;
53 
55  int GetSAttrDat(const TInt& Id, const TStr& AttrName, TFlt& ValX) const;
57  int GetSAttrDat(const TInt& Id, const TInt& AttrId, TFlt& ValX) const;
58 
60  int GetSAttrDat(const TInt& Id, const TStr& AttrName, TStr& ValX) const;
62  int GetSAttrDat(const TInt& Id, const TInt& AttrId, TStr& ValX) const;
63 
65  int DelSAttrDat(const TInt& Id, const TStr& AttrName);
67  int DelSAttrDat(const TInt& Id, const TInt& AttrId);
68 
70  void DelSAttrId(const TInt& Id);
71 
73  void GetSAttrV(const TInt& Id, const TAttrType AttrType, TAttrPrV& AttrV) const;
74 
76  int GetIdVSAttr(const TStr& AttrName, TIntV& IdV) const;
78  int GetIdVSAttr(const TInt& AttrId, TIntV& IdV) const;
79 
81  int AddSAttr(const TStr& Name, const TAttrType& AttrType, TInt& AttrIdX);
82 
84  int GetSAttrId(const TStr& Name, TInt& AttrIdX, TAttrType& AttrTypeX) const;
86  int GetSAttrName(const TInt& AttrId, TStr& NameX, TAttrType& AttrTypeX) const;
87 };
88 
89 
90 class TAttrPair {
91 private:
94 
98 private:
99  int GetIdVSAttr(const TInt& AttrId, const TAttrType Type, TIntPrV& IdV) const;
100 public:
102  FltAttrVals(), StrAttrVals() { }
108  IntAttrVals(SIn), FltAttrVals(SIn), StrAttrVals(SIn) { }
110  void Save(TSOut& SOut) const {
111  AttrNameToId.Save(SOut); AttrIdToName.Save(SOut);
112  IntAttrVals.Save(SOut); FltAttrVals.Save(SOut); StrAttrVals.Save(SOut); }
115 
117  int AddSAttrDat(const TIntPr& Id, const TStr& AttrName, const TInt& Val);
119  int AddSAttrDat(const TIntPr& Id, const TInt& AttrId, const TInt& Val);
120 
122  int AddSAttrDat(const TIntPr& Id, const TStr& AttrName, const TFlt& Val);
124  int AddSAttrDat(const TIntPr& Id, const TInt& AttrId, const TFlt& Val);
125 
127  int AddSAttrDat(const TIntPr& Id, const TStr& AttrName, const TStr& Val);
129  int AddSAttrDat(const TIntPr& Id, const TInt& AttrId, const TStr& Val);
130 
132  int GetSAttrDat(const TIntPr& Id, const TStr& AttrName, TInt& ValX) const;
134  int GetSAttrDat(const TIntPr& Id, const TInt& AttrId, TInt& ValX) const;
135 
137  int GetSAttrDat(const TIntPr& Id, const TStr& AttrName, TFlt& ValX) const;
139  int GetSAttrDat(const TIntPr& Id, const TInt& AttrId, TFlt& ValX) const;
140 
142  int GetSAttrDat(const TIntPr& Id, const TStr& AttrName, TStr& ValX) const;
144  int GetSAttrDat(const TIntPr& Id, const TInt& AttrId, TStr& ValX) const;
145 
147  int DelSAttrDat(const TIntPr& Id, const TStr& AttrName);
149  int DelSAttrDat(const TIntPr& Id, const TInt& AttrId);
150 
152  void DelSAttrId(const TIntPr& Id);
153 
155  void GetSAttrV(const TIntPr& Id, const TAttrType AttrType, TAttrPrV& AttrV) const;
156 
158  int GetIdVSAttr(const TStr& AttrName, TIntPrV& IdV) const;
160  int GetIdVSAttr(const TInt& AttrId, TIntPrV& IdV) const;
161 
163  int AddSAttr(const TStr& Name, const TAttrType& AttrType, TInt& AttrIdX);
164 
166  int GetSAttrId(const TStr& Name, TInt& AttrIdX, TAttrType& AttrTypeX) const;
168  int GetSAttrName(const TInt& AttrId, TStr& NameX, TAttrType& AttrTypeX) const;
169 };
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:101
enum TAttrType_ TAttrType
Types for tables, sparse and dense attributes.
Definition: attr.h:90
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:141
TIntIntStrPrH AttrIdToName
Definition: attr.h:93
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
Definition: dt.h:1293
Definition: fl.h:58
TAttr(const TAttr &Attrs)
Definition: attr.h:18
TIntIntPrPrIntH IntAttrVals
Definition: attr.h:95
Definition: attr.h:4
TAttrPair(TSIn &SIn)
Constructor for loading attributes from a (binary) stream SIn.
Definition: attr.h:107
void Save(TSOut &SOut) const
Saves the attributes to a (binary) stream SOut.
Definition: attr.h:110
size_t GetMemUsed() const
Returns the amount of memory used by sparse attributes.
Definition: attr.h:32
TIntIntStrPrH AttrIdToName
Definition: attr.h:8
::TSize GetMemUsed() const
Definition: hash.h:159
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:96
TStrIntPrH AttrNameToId
Definition: attr.h:92
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:97
TAttr()
Definition: attr.h:16
Definition: dt.h:1044
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:114
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:25
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:319
int GetSAttrId(const TStr &Name, TInt &AttrIdX, TAttrType &AttrTypeX) const
Given the attribute name Name, get the attribute id.
Definition: attr.cpp:224
TIntPrIntH IntAttrVals
Definition: attr.h:10
TAttrPair(const TAttrPair &Attrs)
Definition: attr.h:103
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:29
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:429
TStrIntPrH AttrNameToId
Definition: attr.h:7