oldmap: implement core::container::Container
This commit is contained in:
parent
f4a27b2c7d
commit
1b4eb145f9
7 changed files with 22 additions and 18 deletions
|
|
@ -922,7 +922,7 @@ pub fn install_package(c: &Cargo, src: ~str, wd: &Path, pkg: Package) {
|
|||
}
|
||||
|
||||
pub fn cargo_suggestion(c: &Cargo, fallback: fn()) {
|
||||
if c.sources.size() == 0u {
|
||||
if c.sources.is_empty() {
|
||||
error(~"no sources defined - you may wish to run " +
|
||||
~"`cargo init`");
|
||||
return;
|
||||
|
|
@ -1620,7 +1620,7 @@ pub fn dump_cache(c: &Cargo) {
|
|||
}
|
||||
|
||||
pub fn dump_sources(c: &Cargo) {
|
||||
if c.sources.size() < 1u {
|
||||
if c.sources.is_empty() {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2796,7 +2796,7 @@ pub fn decl_gc_metadata(ccx: @crate_ctxt, llmod_id: ~str) {
|
|||
|
||||
pub fn create_module_map(ccx: @crate_ctxt) -> ValueRef {
|
||||
let elttype = T_struct(~[ccx.int_type, ccx.int_type]);
|
||||
let maptype = T_array(elttype, ccx.module_data.size() + 1u);
|
||||
let maptype = T_array(elttype, ccx.module_data.len() + 1);
|
||||
let map = str::as_c_str(~"_rust_mod_map", |buf| {
|
||||
unsafe {
|
||||
llvm::LLVMAddGlobal(ccx.llmod, maptype, buf)
|
||||
|
|
|
|||
|
|
@ -2799,7 +2799,7 @@ pub fn br_hashmap<V:Copy>() -> HashMap<bound_region, V> {
|
|||
}
|
||||
|
||||
pub fn node_id_to_type(cx: ctxt, id: ast::node_id) -> t {
|
||||
//io::println(fmt!("%?/%?", id, cx.node_types.size()));
|
||||
//io::println(fmt!("%?/%?", id, cx.node_types.len()));
|
||||
match oldsmallintmap::find(*cx.node_types, id as uint) {
|
||||
Some(t) => t,
|
||||
None => cx.sess.bug(
|
||||
|
|
@ -4359,7 +4359,7 @@ pub fn iter_bound_traits_and_supertraits(tcx: ctxt,
|
|||
if f(trait_ty) {
|
||||
// Add all the supertraits to the hash map,
|
||||
// executing <f> on each of them
|
||||
while i < supertrait_map.size() && !fin {
|
||||
while i < supertrait_map.len() && !fin {
|
||||
let init_trait_id = seen_def_ids[i];
|
||||
i += 1;
|
||||
// Add supertraits to supertrait_map
|
||||
|
|
|
|||
|
|
@ -1226,7 +1226,7 @@ impl RegionVarBindings {
|
|||
|
||||
fn construct_graph(&self) -> Graph {
|
||||
let num_vars = self.num_vars();
|
||||
let num_edges = self.constraints.size();
|
||||
let num_edges = self.constraints.len();
|
||||
|
||||
let nodes = vec::from_fn(num_vars, |var_idx| {
|
||||
GraphNode {
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ fn srv_should_build_ast_map() {
|
|||
let source = ~"fn a() { }";
|
||||
do from_str(source) |srv| {
|
||||
do exec(srv) |ctxt| {
|
||||
assert ctxt.ast_map.size() != 0u
|
||||
assert !ctxt.ast_map.is_empty()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
//! A map type - **deprecated**, use `core::hashmap` instead
|
||||
#[forbid(deprecated_mode)];
|
||||
|
||||
use core::container::{Container, Mutable, Map};
|
||||
use core::cmp::Eq;
|
||||
use core::hash::Hash;
|
||||
use core::io::WriterUtil;
|
||||
|
|
@ -161,9 +162,12 @@ pub mod chained {
|
|||
}
|
||||
}
|
||||
|
||||
impl<K:Eq IterBytes Hash Copy, V: Copy> T<K, V> {
|
||||
pure fn size() -> uint { self.count }
|
||||
impl<K: Eq IterBytes Hash, V> T<K, V>: Container {
|
||||
pure fn len(&self) -> uint { self.count }
|
||||
pure fn is_empty(&self) -> bool { self.count == 0 }
|
||||
}
|
||||
|
||||
impl<K:Eq IterBytes Hash Copy, V: Copy> T<K, V> {
|
||||
pure fn contains_key_ref(k: &K) -> bool {
|
||||
let hash = k.hash_keyed(0,0) as uint;
|
||||
match self.search_tbl(k, hash) {
|
||||
|
|
@ -404,7 +408,7 @@ pub fn set_add<K:Eq IterBytes Hash Const Copy>(set: Set<K>, key: K) -> bool {
|
|||
|
||||
/// Convert a set into a vector.
|
||||
pub pure fn vec_from_set<T:Eq IterBytes Hash Copy>(s: Set<T>) -> ~[T] {
|
||||
do vec::build_sized(s.size()) |push| {
|
||||
do vec::build_sized(s.len()) |push| {
|
||||
for s.each_key() |k| {
|
||||
push(k);
|
||||
}
|
||||
|
|
@ -580,7 +584,7 @@ mod tests {
|
|||
debug!("inserting %u -> %u", i, i*i);
|
||||
i += 1u;
|
||||
}
|
||||
assert (hm.size() == num_to_insert);
|
||||
assert (hm.len() == num_to_insert);
|
||||
debug!("-----");
|
||||
debug!("removing evens");
|
||||
i = 0u;
|
||||
|
|
@ -589,7 +593,7 @@ mod tests {
|
|||
assert v;
|
||||
i += 2u;
|
||||
}
|
||||
assert (hm.size() == num_to_insert / 2u);
|
||||
assert (hm.len() == num_to_insert / 2u);
|
||||
debug!("-----");
|
||||
i = 1u;
|
||||
while i < num_to_insert {
|
||||
|
|
@ -611,7 +615,7 @@ mod tests {
|
|||
debug!("inserting %u -> %u", i, i*i);
|
||||
i += 2u;
|
||||
}
|
||||
assert (hm.size() == num_to_insert);
|
||||
assert (hm.len() == num_to_insert);
|
||||
debug!("-----");
|
||||
i = 0u;
|
||||
while i < num_to_insert {
|
||||
|
|
@ -620,7 +624,7 @@ mod tests {
|
|||
i += 1u;
|
||||
}
|
||||
debug!("-----");
|
||||
assert (hm.size() == num_to_insert);
|
||||
assert (hm.len() == num_to_insert);
|
||||
i = 0u;
|
||||
while i < num_to_insert {
|
||||
debug!("get(%u) = %u", i, hm.get(i));
|
||||
|
|
@ -653,10 +657,10 @@ mod tests {
|
|||
let key = ~"k";
|
||||
let map = HashMap::<~str, ~str>();
|
||||
map.insert(key, ~"val");
|
||||
assert (map.size() == 1);
|
||||
assert (map.len() == 1);
|
||||
assert (map.contains_key_ref(&key));
|
||||
map.clear();
|
||||
assert (map.size() == 0);
|
||||
assert (map.len() == 0);
|
||||
assert (!map.contains_key_ref(&key));
|
||||
}
|
||||
|
||||
|
|
@ -667,7 +671,7 @@ mod tests {
|
|||
(~"b", 2),
|
||||
(~"c", 3)
|
||||
]);
|
||||
assert map.size() == 3u;
|
||||
assert map.len() == 3u;
|
||||
assert map.get(~"a") == 1;
|
||||
assert map.get(~"b") == 2;
|
||||
assert map.get(~"c") == 3;
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ fn gen_search_keys(graph: graph, n: uint) -> ~[node_id] {
|
|||
let keys = oldmap::HashMap::<node_id, ()>();
|
||||
let r = rand::Rng();
|
||||
|
||||
while keys.size() < n {
|
||||
while keys.len() < n {
|
||||
let k = r.gen_uint_range(0u, graph.len());
|
||||
|
||||
if graph[k].len() > 0u && vec::any(graph[k], |i| {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue