1.5.3.8 Filling and Generating

Filling



fill(f,f,& )

Set every item in a range to a particular value.



fill_n(o,n,& )

Set n items to a particular value.



Generating



generate(f,f,pfunc)

Fill a range with generated values.



generate_n(o,n,pfunc)

Generate a specified number of values.



Filtering , should used on sorted container



f unique(f,f)
f unique(f,f,bpred)

Collapse each group of consecutive duplicate values to a single value, and return an iterator pointing to the end of the modified range.



o unique_copy(i,i,o)
o unique_copy(i,i,o,bpred)

Copy a range of values, performing the same action as unique above, and return an iterator pointing to the end of the new range.



int myints[] = {10,20,20,20,30,30,20,20,10}; 
  std::vector<int> myvector (myints,myints+9); 
 
  // using default comparison: 
  std::vector<int>::iterator it; 
  it = std::unique (myvector.begin(), myvector.end()); 
  // 10 20 30 20 10 ?  ?  ?  ?

Heap




make_heap(r,r)
make_heap(r,r,bpred)

Make a range of values into a heap.

It nees random iterator. priority_queue use them inside. You don’t use them directly



o pop_heap(r,r)
o pop_heap(r,r,bpred)

Delete the first value from a heap.



push_heap(r,r)
push_heap(r,r,bpred)

Insert the last value of a range into a heap.



sort_heap(r,r)
sort_heap(r,r,bpred)

Sort a heap.