diff options
| author | Tim Foley <tfoleyNV@users.noreply.github.com> | 2017-07-06 13:15:26 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-07-06 13:15:26 -0700 |
| commit | af8c0eae90c76d2c8f745badf6f743cefe15f777 (patch) | |
| tree | 57632ee0f4b4944b311c0e50173fbeab0fe7d109 /source/core/int-set.h | |
| parent | 21a14cb4e0d578bc4f8a460016269a1199cac0da (diff) | |
| parent | 9795ed654e7b8daaff0bef1ccae1507ff659d3bd (diff) | |
Merge pull request #54 from tfoleyNV/falcor-fixes
Fix issues found during testing of v0.4.0 with Falcor
Diffstat (limited to 'source/core/int-set.h')
| -rw-r--r-- | source/core/int-set.h | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/source/core/int-set.h b/source/core/int-set.h index a56a58d64..6b6f5e7a8 100644 --- a/source/core/int-set.h +++ b/source/core/int-set.h @@ -46,7 +46,7 @@ namespace Slang { SetMax(maxVal); } - int Size() const + UInt Size() const { return buffer.Count()*32; } @@ -57,40 +57,40 @@ namespace Slang } void SetAll() { - for (int i = 0; i<buffer.Count(); i++) + for (UInt i = 0; i<buffer.Count(); i++) buffer[i] = 0xFFFFFFFF; } - void Resize(int size) + void Resize(UInt size) { - int oldBufferSize = buffer.Count(); + UInt oldBufferSize = buffer.Count(); buffer.SetSize((size+31)>>5); if (buffer.Count() > oldBufferSize) memset(buffer.Buffer()+oldBufferSize, 0, (buffer.Count()-oldBufferSize) * sizeof(int)); } void Clear() { - for (int i = 0; i<buffer.Count(); i++) + for (UInt i = 0; i<buffer.Count(); i++) buffer[i] = 0; } - void Add(int val) + void Add(UInt val) { - int id = val>>5; + UInt id = val>>5; if (id < buffer.Count()) buffer[id] |= (1<<(val&31)); else { - int oldSize = buffer.Count(); + UInt oldSize = buffer.Count(); buffer.SetSize(id+1); memset(buffer.Buffer() + oldSize, 0, (buffer.Count()-oldSize)*sizeof(int)); buffer[id] |= (1<<(val&31)); } } - void Remove(int val) + void Remove(UInt val) { if ((val>>5) < buffer.Count()) buffer[(val>>5)] &= ~(1<<(val&31)); } - bool Contains(int val) const + bool Contains(UInt val) const { if ((val>>5) >= buffer.Count()) return false; @@ -98,7 +98,7 @@ namespace Slang } void UnionWith(const IntSet & set) { - for (int i = 0; i<Math::Min(set.buffer.Count(), buffer.Count()); i++) + for (UInt i = 0; i<Math::Min(set.buffer.Count(), buffer.Count()); i++) { buffer[i] |= set.buffer[i]; } @@ -109,7 +109,7 @@ namespace Slang { if (buffer.Count() != set.buffer.Count()) return false; - for (int i = 0; i<buffer.Count(); i++) + for (UInt i = 0; i<buffer.Count(); i++) if (buffer[i] != set.buffer[i]) return false; return true; @@ -122,7 +122,7 @@ namespace Slang { if (set.buffer.Count() < buffer.Count()) memset(buffer.Buffer() + set.buffer.Count(), 0, (buffer.Count()-set.buffer.Count())*sizeof(int)); - for (int i = 0; i<Math::Min(set.buffer.Count(), buffer.Count()); i++) + for (UInt i = 0; i<Math::Min(set.buffer.Count(), buffer.Count()); i++) { buffer[i] &= set.buffer[i]; } @@ -131,26 +131,26 @@ namespace Slang { rs.buffer.SetSize(Math::Max(set1.buffer.Count(), set2.buffer.Count())); rs.Clear(); - for (int i = 0; i<set1.buffer.Count(); i++) + for (UInt i = 0; i<set1.buffer.Count(); i++) rs.buffer[i] |= set1.buffer[i]; - for (int i = 0; i<set2.buffer.Count(); i++) + for (UInt i = 0; i<set2.buffer.Count(); i++) rs.buffer[i] |= set2.buffer[i]; } static void Intersect(IntSet & rs, const IntSet & set1, const IntSet & set2) { rs.buffer.SetSize(Math::Min(set1.buffer.Count(), set2.buffer.Count())); - for (int i = 0; i<rs.buffer.Count(); i++) + for (UInt i = 0; i<rs.buffer.Count(); i++) rs.buffer[i] = set1.buffer[i] & set2.buffer[i]; } static void Subtract(IntSet & rs, const IntSet & set1, const IntSet & set2) { rs.buffer.SetSize(set1.buffer.Count()); - for (int i = 0; i<Math::Min(set1.buffer.Count(), set2.buffer.Count()); i++) + for (UInt i = 0; i<Math::Min(set1.buffer.Count(), set2.buffer.Count()); i++) rs.buffer[i] = set1.buffer[i] & (~set2.buffer[i]); } static bool HasIntersection(const IntSet & set1, const IntSet & set2) { - for (int i = 0; i<Math::Min(set1.buffer.Count(), set2.buffer.Count()); i++) + for (UInt i = 0; i<Math::Min(set1.buffer.Count(), set2.buffer.Count()); i++) { if (set1.buffer[i] & set2.buffer[i]) return true; |
