core: Change the argument order for vec::contains, vec::count

This commit is contained in:
Brian Anderson 2012-02-11 17:54:49 -08:00
parent 1040b47078
commit d2debed605
8 changed files with 12 additions and 12 deletions

View file

@ -800,7 +800,7 @@ fn cmd_search(c: cargo) {
let tags = vec::slice(c.opts.free, 3u, vec::len(c.opts.free)); let tags = vec::slice(c.opts.free, 3u, vec::len(c.opts.free));
for_each_package(c, { |s, p| for_each_package(c, { |s, p|
if (str::contains(p.name, name) || name == "*") && if (str::contains(p.name, name) || name == "*") &&
vec::all(tags, { |t| vec::contains(t, p.tags) }) { vec::all(tags, { |t| vec::contains(p.tags, t) }) {
print_pkg(s, p); print_pkg(s, p);
n += 1; n += 1;
} }

View file

@ -97,7 +97,7 @@ fn iter_crate_data(cstore: cstore, i: fn(ast::crate_num, crate_metadata)) {
} }
fn add_used_crate_file(cstore: cstore, lib: str) { fn add_used_crate_file(cstore: cstore, lib: str) {
if !vec::contains(lib, p(cstore).used_crate_files) { if !vec::contains(p(cstore).used_crate_files, lib) {
p(cstore).used_crate_files += [lib]; p(cstore).used_crate_files += [lib];
} }
} }
@ -109,7 +109,7 @@ fn get_used_crate_files(cstore: cstore) -> [str] {
fn add_used_library(cstore: cstore, lib: str) -> bool { fn add_used_library(cstore: cstore, lib: str) -> bool {
assert lib != ""; assert lib != "";
if vec::contains(lib, p(cstore).used_libraries) { ret false; } if vec::contains(p(cstore).used_libraries, lib) { ret false; }
p(cstore).used_libraries += [lib]; p(cstore).used_libraries += [lib];
ret true; ret true;
} }

View file

@ -98,7 +98,7 @@ fn check_exhaustive(tcx: ty::ctxt, sp:span, scrut_ty:ty::t, pats:[@pat]) {
} }
} }
fn not_represented(v: [def_id], &&vinfo: variant_info) -> bool { fn not_represented(v: [def_id], &&vinfo: variant_info) -> bool {
!vec::contains(vinfo.id, v) !vec::contains(v, vinfo.id)
} }
// Could be more efficient (bitvectors?) // Could be more efficient (bitvectors?)
alt vec::find(variants, bind not_represented(represented,_)) { alt vec::find(variants, bind not_represented(represented,_)) {

View file

@ -109,7 +109,7 @@ fn check_fn_cap_clause(cx: ctx,
let check_var = fn@(&&cap_item: @capture_item) { let check_var = fn@(&&cap_item: @capture_item) {
let cap_def = cx.tcx.def_map.get(cap_item.id); let cap_def = cx.tcx.def_map.get(cap_item.id);
let cap_def_id = ast_util::def_id_of_def(cap_def).node; let cap_def_id = ast_util::def_id_of_def(cap_def).node;
if !vec::contains(cap_def_id, freevar_ids) { if !vec::contains(freevar_ids, cap_def_id) {
let ty = ty::node_id_to_type(cx.tcx, cap_def_id); let ty = ty::node_id_to_type(cx.tcx, cap_def_id);
checker(cx, ty, cap_item.span); checker(cx, ty, cap_item.span);
} }

View file

@ -317,7 +317,7 @@ fn check_unused_imports(e: @env) {
e.imports.items {|k, v| e.imports.items {|k, v|
alt v { alt v {
resolved(_, _, _, _, name, sp) { resolved(_, _, _, _, name, sp) {
if !vec::contains(k, e.used_imports.data) { if !vec::contains(e.used_imports.data, k) {
e.sess.span_warn(sp, "unused import " + name); e.sess.span_warn(sp, "unused import " + name);
} }
} }
@ -1279,7 +1279,7 @@ fn found_view_item(e: env, id: node_id) -> def {
fn lookup_import(e: env, defid: def_id, ns: namespace) -> option<def> { fn lookup_import(e: env, defid: def_id, ns: namespace) -> option<def> {
// Imports are simply ignored when resolving themselves. // Imports are simply ignored when resolving themselves.
if vec::contains(defid.node, e.ignored_imports) { ret none; } if vec::contains(e.ignored_imports, defid.node) { ret none; }
alt e.imports.get(defid.node) { alt e.imports.get(defid.node) {
todo(node_id, name, path, span, scopes) { todo(node_id, name, path, span, scopes) {
resolve_import(e, local_def(node_id), name, *path, span, scopes); resolve_import(e, local_def(node_id), name, *path, span, scopes);
@ -1344,7 +1344,7 @@ fn lookup_in_globs(e: env, globs: [glob_imp_def], sp: span, id: ident,
ns: namespace, dr: dir) -> option<glob_imp_def> { ns: namespace, dr: dir) -> option<glob_imp_def> {
alt def.item.node { alt def.item.node {
ast::view_item_import_glob(_, id) { ast::view_item_import_glob(_, id) {
if vec::contains(id, e.ignored_imports) { ret none; } if vec::contains(e.ignored_imports, id) { ret none; }
} }
_ { _ {
e.sess.span_bug(sp, "lookup_in_globs: not a glob"); e.sess.span_bug(sp, "lookup_in_globs: not a glob");

View file

@ -1387,7 +1387,7 @@ fn occurs_check_fails(tcx: ctxt, sp: option<span>, vid: int, rt: t) ->
if !type_has_vars(rt) { ret false; } if !type_has_vars(rt) { ret false; }
// Occurs check! // Occurs check!
if vec::contains(vid, vars_in_type(tcx, rt)) { if vec::contains(vars_in_type(tcx, rt), vid) {
alt sp { alt sp {
some(s) { some(s) {
// Maybe this should be span_err -- however, there's an // Maybe this should be span_err -- however, there's an

View file

@ -2656,7 +2656,7 @@ fn check_enum_variants(ccx: @crate_ctxt, sp: span, vs: [ast::variant],
} }
_ {} _ {}
} }
if vec::contains(disr_val, disr_vals) { if vec::contains(disr_vals, disr_val) {
ccx.tcx.sess.span_err(v.span, ccx.tcx.sess.span_err(v.span,
"discriminator value already exists."); "discriminator value already exists.");
} }

View file

@ -693,7 +693,7 @@ Function: contains
Return true if a vector contains an element with the given value Return true if a vector contains an element with the given value
*/ */
fn contains<T>(x: T, v: [T]) -> bool { fn contains<T>(v: [T], x: T) -> bool {
for elt: T in v { if x == elt { ret true; } } for elt: T in v { if x == elt { ret true; } }
ret false; ret false;
} }
@ -703,7 +703,7 @@ Function: count
Returns the number of elements that are equal to a given value Returns the number of elements that are equal to a given value
*/ */
fn count<T>(x: T, v: [const T]) -> uint { fn count<T>(v: [const T], x: T) -> uint {
let cnt = 0u; let cnt = 0u;
for elt: T in v { if x == elt { cnt += 1u; } } for elt: T in v { if x == elt { cnt += 1u; } }
ret cnt; ret cnt;