Partitions ExampleThe following program shows the operations that are supported by #include <LEDA/core/partition.h> #include <LEDA/core/list.h> int main() { leda::partition P; leda::list<leda::partition_item> L; //stores partition_items of P //generate 100 blocks containing one item each for(int i=0; i<100; i++) { leda::partition_item p=P.make_block(); L.append(p); } std::cout << "Number of blocks: " << P.number_of_blocks() << std::endl; //unite all blocks to one big block leda::partition_item p; forall(p,L) P.union_blocks(p,L.tail()); std::cout << "Number of blocks: " << P.number_of_blocks() << std::endl; std::cout << "Size of block containing last item in L: " << P.size(L.tail()) << std::endl; if (P.same_block(L.head(),L.tail())) { std::cout << "head and tail of L belong to one block" << std::endl; } P.split(L); //turn all items in L to singleton blocks std::cout << "Number of blocks: " << P.number_of_blocks() << std::endl; return 0; } |
See also:Manual Entries:
|