22 #include "ns3/fatal-error.h"
35 m_currentVectorBitSize (0),
49 : m_nixVector (o.m_nixVector),
51 m_currentVectorBitSize (o.m_currentVectorBitSize),
52 m_totalBitSize (o.m_totalBitSize)
92 if (numberOfBits > 32)
94 NS_FATAL_ERROR (
"Can't add more than 32 bits to a nix-vector at one time");
120 uint32_t tempBits = newBits;
164 if (numberOfBits > 32)
166 NS_FATAL_ERROR (
"Can't extract more than 32 bits to a nix-vector at one time");
169 uint32_t vectorIndex = 0;
170 uint32_t extractedBits = 0;
173 if (numberOfBits > totalRemainingBits)
175 NS_FATAL_ERROR (
"You've tried to extract too many bits of the Nix-vector, " <<
this <<
". NumberBits: "
176 << numberOfBits <<
" Remaining: " << totalRemainingBits);
179 if (numberOfBits <= 0)
181 NS_FATAL_ERROR (
"You've specified a number of bits for Nix-vector <= 0!");
188 vectorIndex = ((totalRemainingBits-1) / 32);
194 if ((numberOfBits-1) > ((totalRemainingBits-1) % 32))
196 extractedBits =
m_nixVector.at (vectorIndex) << (32 - (totalRemainingBits % 32));
197 extractedBits = extractedBits >> ((32 - (totalRemainingBits % 32))
198 - (numberOfBits - (totalRemainingBits % 32)));
200 >> (32 - (numberOfBits - (totalRemainingBits % 32))));
202 return extractedBits;
207 extractedBits =
m_nixVector.at (vectorIndex) << (32 - (totalRemainingBits % 32));
208 extractedBits = extractedBits >> (32 - (numberOfBits));
210 return extractedBits;
217 uint32_t totalSizeInBytes = 0;
221 return totalSizeInBytes;
228 uint32_t* p = buffer;
231 if (size + 4 <= maxSize)
242 if (size + 4 <= maxSize)
254 if (size + 4 <= maxSize)
266 if (size + 4 <= maxSize)
285 const uint32_t* p = buffer;
286 uint32_t sizeCheck = size - 4;
303 while (sizeCheck > 0)
315 return (sizeCheck != 0) ? 0 : 1;
323 std::vector<uint32_t>::const_reverse_iterator rIter;
326 uint32_t numBits =
BitCount (*rIter);
371 uint32_t bitCount = 0;
373 if (numberOfNeighbors < 2)
379 for (numberOfNeighbors -= 1; numberOfNeighbors != 0; numberOfNeighbors >>= 1)
393 for (; bitCount > 0; bitCount--)
401 for (; bitCount > 1; bitCount--)
410 os << decimalNum % 2;
428 if ((uint32_t)(
sizeof (uint32_t)*8) > bitCount)
430 for (uint32_t i = ((
sizeof (uint32_t)*8)-bitCount); i > 0; i--)
440 os << decimalNum % 2;