/* modifying.pure -- Pure interface for C++ STL modifying algorithms
    
Copyright (c) 2011 by Peter Summerland <p.summerland@gmail.com>.

All rights reserved.

This software is is part of pure-stlvec, an addon to the Pure Programming
Language (http://code.google.com/p/pure-lang/).

This software is distributed under a BSD-style license in the hope that it
will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the COPYING file
included with the pure-stlvec distribution package for details.

*/

using stlvec;
using "lib:stlalgorithm";

namespace stl;

private extern int  stl_sva_copy(expr* rng1, expr* rng2);
private extern int  stl_sva_copy_backward(expr* rng1, expr* rng2);
private extern int  stl_sva_swap_ranges(expr* rng1, expr* rng2);
private extern int  stl_sva_transform(expr* rng1, expr* rng2, expr* unary_op);
private extern int  stl_sva_transform_2(expr* rng1, expr* rng2, expr* rng3,
                                    expr* bin_op);
private extern void stl_sva_replace_if(expr* rng, expr* pred, expr* val);
private extern int  stl_sva_replace_copy_if(expr* rng1, expr* rng2, expr* pred,
                                        expr* val);
private extern void stl_sva_fill(expr* rng, expr* val);
private extern void stl_sva_fill_n(expr* rng, int n, expr* val);
private extern void stl_sva_generate(expr* rng1, expr* gen);
private extern void stl_sva_generate_n(expr*, int n, expr* gen);
private extern int  stl_sva_remove_if(expr* rng1, expr* pred);
private extern int  stl_sva_remove_copy_if(expr* rng1, expr* rng2, expr* pred);
private extern int  stl_sva_unique(expr* rng1, expr* bin_pred);
private extern int  stl_sva_unique_copy(expr* rng1, expr* rng2, expr* bin_pred);
private extern void stl_sva_reverse(expr* rng1);
private extern int  stl_sva_reverse_copy(expr* rng1, expr* rng2);
private extern void stl_sva_rotate(expr* rng);
private extern void stl_sva_rotate_copy(expr* rng1, expr* rng2);
private extern void stl_sva_random_shuffle(expr* rng, int seed);  
private extern int  stl_sva_partition(expr* rng, expr* pred);
private extern int  stl_sva_stable_partition(expr* rng, expr* pred);

copy src::svrng trg::mutable_svrng = stl_sva_copy src trg;

copy_backward src::svrng trg::mutable_svrng = 
  stl_sva_copy_backward src trg;

swap_ranges rng1::mutable_svrng rng2::mutable_svrng = 
  stl_sva_swap_ranges rng1 rng2;

transform src::svrng trg::mutable_svrng f = stl_sva_transform src trg f;

transform_2 src1::svrng src2::svrng trg::mutable_svrng f = 
  stl_sva_transform_2 src1 src2 trg f;

replace_if rng::mutable_svrng pred val = stl_sva_replace_if rng pred val;

replace_copy_if src::svrng trg::mutable_svrng pred val =
  stl_sva_replace_copy_if src trg pred val; 

replace_copy src::svrng trg::mutable_svrng x y =
  replace_copy_if src trg (x==) y;

fill rng::mutable_svrng x = stl_sva_fill rng x;

fill_n rng::mutable_svrng n::int x = stl_sva_fill_n rng n x;

generate rng::mutable_svrng gen = stl_sva_generate rng gen;

generate_n rng::mutable_svrng n::int gen = stl_sva_generate_n rng n gen;

remove_if rng::mutable_svrng pred = stl_sva_remove_if rng pred;

remove rng::mutable_svrng x = stl_sva_remove_if rng (x==);

remove_copy_if src::svrng trg::mutable_svrng pred =
  stl_sva_remove_copy_if src trg pred; 

remove_copy src::svrng trg::mutable_svrng x =
  remove_copy_if src trg (x==);

unique rng::mutable_svrng pred = stl_sva_unique rng pred;

unique_copy src::svrng trg::mutable_svrng pred = stl_sva_unique_copy src trg pred; 

reverse rng::mutable_svrng = stl_sva_reverse rng;

reverse_copy src::svrng trg::mutable_svrng = stl_sva_reverse_copy src trg; 

rotate rng::mutable_svrng = stl_sva_rotate rng;

rotate_copy src::svrng trg::mutable_svrng = stl_sva_rotate_copy src trg;

random_shuffle rng::mutable_svrng seed::int = stl_sva_random_shuffle rng seed;

partition rng::mutable_svrng pred = stl_sva_partition rng pred;

stable_partition rng::mutable_svrng pred = stl_sva_stable_partition rng pred;


