This is an archive of the discontinued LLVM Phabricator instance.

SetVector: Add front, pop_front and additional constructor.
AbandonedPublic

Authored by MatzeB on Mar 29 2016, 2:37 PM.

Details

Summary

front() and pop_front() allow convenient usage of a std::dequeue as the
underlying vector type.
The new constructor allows to pass in instances of the underlying set/vector.
This is useful when using a BitSet as the Set type to be able to initialized
it to a maximum element size.

Diff Detail

Repository
rL LLVM

Event Timeline

MatzeB updated this revision to Diff 51986.Mar 29 2016, 2:37 PM
MatzeB retitled this revision from to SetVector: Add front, pop_front and resize operations.
MatzeB updated this object.
MatzeB added reviewers: dblaikie, echristo, qcolombet.
MatzeB set the repository for this revision to rL LLVM.
MatzeB added a subscriber: llvm-commits.
dblaikie edited edge metadata.Mar 29 2016, 10:26 PM
dblaikie added a subscriber: dblaikie.

Test cases?
Got use cases in mind? (specific new/incoming patches to LLVM projects that
will use this functionality)

& 'resize' seems like the wrong name for a set or map operation - perhaps
"reserve"? (I think there was a recent change for this rename in DenseMap,
right?)

MatzeB updated this revision to Diff 52143.Mar 30 2016, 3:28 PM
MatzeB edited edge metadata.

Added unittests for the new methods and the missing tests for nearly all of the other methods.

Test cases?
Got use cases in mind? (specific new/incoming patches to LLVM projects that
will use this functionality)

See http://reviews.llvm.org/D18427

& 'resize' seems like the wrong name for a set or map operation - perhaps
"reserve"? (I think there was a recent change for this rename in DenseMap,
right?)

It is still called resize() in DenseSet, SmallPtrSet and BitVector so I'd like to keep that name for consistency. Of course someone else can rename them all to reserve() in the future.

MatzeB updated this revision to Diff 52448.Apr 1 2016, 5:05 PM
MatzeB retitled this revision from SetVector: Add front, pop_front and resize operations to SetVector: Add front, pop_front and additional constructor..
MatzeB updated this object.

New version which does not introduce the resize() (or reserve()) operation anymore in favor of a constructor allowing to supply (empty) instances for the vector and set.

That seems like a somewhat strange API - calling reserve down into the
vector (& possibly the set, for things like DenseSet) seems more
appropriate, no?

That seems like a somewhat strange API - calling reserve down into the
vector (& possibly the set, for things like DenseSet) seems more
appropriate, no?

After the discussions here I felt that reserve()/resize() are details of the underlying set not necessarily a common agreed interface supported by all sets, what if the next set implementation has additional methods for tuning? An alternative to that strange constructor would be to expose the set object so people can call reserve()/resize() on it directly though it breaks isolation.

Yeah, not sure - wouldn't mind some other voices here to see how people
feel.

Reserve isn't part of any STL concept so far as I can tell, so, yes, to
that degree it is an implementation detail.

MatzeB abandoned this revision.Dec 15 2016, 3:46 PM

Abandoning for lack of progress and use case. The motivating pass simply uses a combination of BitVector+Set instead of a SetVector now.