llvm.org GIT mirror llvm / fab4c9e
Add an all() method to BitVector, for testing whether all bits are set. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114830 91177308-0d34-0410-b5e6-96231b3b80d8 Dan Gohman 9 years ago
4 changed file(s) with 27 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
124124 if (Bits[i] != 0)
125125 return true;
126126 return false;
127 }
128
129 /// all - Returns true if all bits are set.
130 bool all() const {
131 // TODO: Optimize this.
132 return count() == size();
127133 }
128134
129135 /// none - Returns true if none of the bits are set.
184184 if (isSmall())
185185 return getSmallBits() != 0;
186186 return getPointer()->any();
187 }
188
189 /// all - Returns true if all bits are set.
190 bool all() const {
191 if (isSmall())
192 return getSmallBits() == (uintptr_t(1) << getSmallSize()) - 1;
193 return getPointer()->all();
187194 }
188195
189196 /// none - Returns true if none of the bits are set.
2121 EXPECT_EQ(0U, Vec.count());
2222 EXPECT_EQ(0U, Vec.size());
2323 EXPECT_FALSE(Vec.any());
24 EXPECT_TRUE(Vec.all());
2425 EXPECT_TRUE(Vec.none());
2526 EXPECT_TRUE(Vec.empty());
2627
2829 EXPECT_EQ(5U, Vec.count());
2930 EXPECT_EQ(5U, Vec.size());
3031 EXPECT_TRUE(Vec.any());
32 EXPECT_TRUE(Vec.all());
3133 EXPECT_FALSE(Vec.none());
3234 EXPECT_FALSE(Vec.empty());
3335
3537 EXPECT_EQ(5U, Vec.count());
3638 EXPECT_EQ(11U, Vec.size());
3739 EXPECT_TRUE(Vec.any());
40 EXPECT_FALSE(Vec.all());
3841 EXPECT_FALSE(Vec.none());
3942 EXPECT_FALSE(Vec.empty());
4043
4245 EXPECT_EQ(6U, Inv.count());
4346 EXPECT_EQ(11U, Inv.size());
4447 EXPECT_TRUE(Inv.any());
48 EXPECT_FALSE(Inv.all());
4549 EXPECT_FALSE(Inv.none());
4650 EXPECT_FALSE(Inv.empty());
4751
122126 EXPECT_EQ(0U, Vec.count());
123127 EXPECT_EQ(130U, Vec.size());
124128 EXPECT_FALSE(Vec.any());
129 EXPECT_FALSE(Vec.all());
125130 EXPECT_TRUE(Vec.none());
126131 EXPECT_FALSE(Vec.empty());
127132
129134 EXPECT_EQ(0U, Inv.count());
130135 EXPECT_EQ(0U, Inv.size());
131136 EXPECT_FALSE(Inv.any());
137 EXPECT_TRUE(Inv.all());
132138 EXPECT_TRUE(Inv.none());
133139 EXPECT_TRUE(Inv.empty());
134140
136142 EXPECT_EQ(0U, Vec.count());
137143 EXPECT_EQ(0U, Vec.size());
138144 EXPECT_FALSE(Vec.any());
145 EXPECT_TRUE(Vec.all());
139146 EXPECT_TRUE(Vec.none());
140147 EXPECT_TRUE(Vec.empty());
141148 }
1818 EXPECT_EQ(0U, Vec.count());
1919 EXPECT_EQ(0U, Vec.size());
2020 EXPECT_FALSE(Vec.any());
21 EXPECT_TRUE(Vec.all());
2122 EXPECT_TRUE(Vec.none());
2223 EXPECT_TRUE(Vec.empty());
2324
2526 EXPECT_EQ(5U, Vec.count());
2627 EXPECT_EQ(5U, Vec.size());
2728 EXPECT_TRUE(Vec.any());
29 EXPECT_TRUE(Vec.all());
2830 EXPECT_FALSE(Vec.none());
2931 EXPECT_FALSE(Vec.empty());
3032
3234 EXPECT_EQ(5U, Vec.count());
3335 EXPECT_EQ(11U, Vec.size());
3436 EXPECT_TRUE(Vec.any());
37 EXPECT_FALSE(Vec.all());
3538 EXPECT_FALSE(Vec.none());
3639 EXPECT_FALSE(Vec.empty());
3740
3942 EXPECT_EQ(6U, Inv.count());
4043 EXPECT_EQ(11U, Inv.size());
4144 EXPECT_TRUE(Inv.any());
45 EXPECT_FALSE(Inv.all());
4246 EXPECT_FALSE(Inv.none());
4347 EXPECT_FALSE(Inv.empty());
4448
119123 EXPECT_EQ(0U, Vec.count());
120124 EXPECT_EQ(130U, Vec.size());
121125 EXPECT_FALSE(Vec.any());
126 EXPECT_FALSE(Vec.all());
122127 EXPECT_TRUE(Vec.none());
123128 EXPECT_FALSE(Vec.empty());
124129
126131 EXPECT_EQ(0U, Inv.count());
127132 EXPECT_EQ(0U, Inv.size());
128133 EXPECT_FALSE(Inv.any());
134 EXPECT_TRUE(Inv.all());
129135 EXPECT_TRUE(Inv.none());
130136 EXPECT_TRUE(Inv.empty());
131137
133139 EXPECT_EQ(0U, Vec.count());
134140 EXPECT_EQ(0U, Vec.size());
135141 EXPECT_FALSE(Vec.any());
142 EXPECT_TRUE(Vec.all());
136143 EXPECT_TRUE(Vec.none());
137144 EXPECT_TRUE(Vec.empty());
138145 }