rename Linear{Map,Set} => Hash{Map,Set}

This commit is contained in:
Daniel Micay 2013-04-03 09:28:36 -04:00
parent 44029a5bbc
commit cc148b58ff
75 changed files with 523 additions and 523 deletions

View file

@ -13,9 +13,9 @@
extern mod std;
use core::hashmap::LinearMap;
use core::hashmap::HashMap;
pub type header_map = LinearMap<~str, @mut ~[@~str]>;
pub type header_map = HashMap<~str, @mut ~[@~str]>;
// the unused ty param is necessary so this gets monomorphized
pub fn request<T:Copy>(req: &header_map) {

View file

@ -13,7 +13,7 @@ extern mod std;
use core::io;
use std::time;
use std::treemap::TreeMap;
use core::hashmap::{LinearMap, LinearSet};
use core::hashmap::{HashMap, HashSet};
use core::trie::TrieMap;
fn timed(label: &str, f: &fn()) {
@ -102,7 +102,7 @@ fn main() {
{
let rng = core::rand::seeded_rng([1, 1, 1, 1, 1, 1, 1]);
let mut set = LinearSet::new();
let mut set = HashSet::new();
while set.len() != n_keys {
let next = rng.next() as uint;
if set.insert(next) {
@ -131,21 +131,21 @@ fn main() {
vector(&mut map, n_keys, rand);
}
io::println("\nLinearMap:");
io::println("\nHashMap:");
{
let mut map = LinearMap::new::<uint, uint>();
let mut map = HashMap::new::<uint, uint>();
ascending(&mut map, n_keys);
}
{
let mut map = LinearMap::new::<uint, uint>();
let mut map = HashMap::new::<uint, uint>();
descending(&mut map, n_keys);
}
{
io::println(" Random integers:");
let mut map = LinearMap::new::<uint, uint>();
let mut map = HashMap::new::<uint, uint>();
vector(&mut map, n_keys, rand);
}

View file

@ -9,7 +9,7 @@
// except according to those terms.
extern mod std;
use core::hashmap::LinearSet;
use core::hashmap::HashSet;
use std::bitv::BitvSet;
use std::treemap::TreeSet;
use core::io::WriterUtil;
@ -158,9 +158,9 @@ fn main() {
{
let rng = rand::seeded_rng(seed);
let mut results = empty_results();
results.bench_int(rng, num_keys, max, || LinearSet::new::<uint>());
results.bench_str(rng, num_keys, || LinearSet::new::<~str>());
write_results("core::hashmap::LinearSet", &results);
results.bench_int(rng, num_keys, max, || HashSet::new::<uint>());
results.bench_str(rng, num_keys, || HashSet::new::<~str>());
write_results("core::hashmap::HashSet", &results);
}
{

View file

@ -24,7 +24,7 @@ use std::arc;
use std::time;
use std::deque::Deque;
use std::par;
use core::hashmap::{LinearMap, LinearSet};
use core::hashmap::{HashMap, HashSet};
use core::io::WriterUtil;
use core::int::abs;
use core::rand::RngUtil;
@ -81,7 +81,7 @@ fn make_edges(scale: uint, edgefactor: uint) -> ~[(node_id, node_id)] {
fn make_graph(N: uint, edges: ~[(node_id, node_id)]) -> graph {
let mut graph = do vec::from_fn(N) |_i| {
LinearSet::new()
HashSet::new()
};
do vec::each(edges) |e| {
@ -104,7 +104,7 @@ fn make_graph(N: uint, edges: ~[(node_id, node_id)]) -> graph {
}
fn gen_search_keys(graph: &[~[node_id]], n: uint) -> ~[node_id] {
let mut keys = LinearSet::new();
let mut keys = HashSet::new();
let r = rand::Rng();
while keys.len() < n {

View file

@ -15,13 +15,13 @@
extern mod std;
use std::sort;
use core::hashmap::LinearMap;
use core::hashmap::HashMap;
use core::io::ReaderUtil;
use core::comm::{stream, Port, Chan};
use core::cmp::Ord;
// given a map, print a sorted version of it
fn sort_and_fmt(mm: &LinearMap<~[u8], uint>, total: uint) -> ~str {
fn sort_and_fmt(mm: &HashMap<~[u8], uint>, total: uint) -> ~str {
fn pct(xx: uint, yy: uint) -> float {
return (xx as float) * 100f / (yy as float);
}
@ -67,7 +67,7 @@ fn sort_and_fmt(mm: &LinearMap<~[u8], uint>, total: uint) -> ~str {
}
// given a map, search for the frequency of a pattern
fn find(mm: &LinearMap<~[u8], uint>, key: ~str) -> uint {
fn find(mm: &HashMap<~[u8], uint>, key: ~str) -> uint {
match mm.find(&str::to_bytes(str::to_lower(key))) {
option::None => { return 0u; }
option::Some(&num) => { return num; }
@ -75,7 +75,7 @@ fn find(mm: &LinearMap<~[u8], uint>, key: ~str) -> uint {
}
// given a map, increment the counter for a key
fn update_freq(mm: &mut LinearMap<~[u8], uint>, key: &[u8]) {
fn update_freq(mm: &mut HashMap<~[u8], uint>, key: &[u8]) {
let key = vec::slice(key, 0, key.len()).to_vec();
let newval = match mm.pop(&key) {
Some(v) => v + 1,
@ -103,7 +103,7 @@ fn windows_with_carry(bb: &[u8], nn: uint,
fn make_sequence_processor(sz: uint, from_parent: comm::Port<~[u8]>,
to_parent: comm::Chan<~str>) {
let mut freqs: LinearMap<~[u8], uint> = LinearMap::new();
let mut freqs: HashMap<~[u8], uint> = HashMap::new();
let mut carry: ~[u8] = ~[];
let mut total: uint = 0u;

View file

@ -25,7 +25,7 @@
// writes pbm image to output path
use core::io::WriterUtil;
use core::hashmap::LinearMap;
use core::hashmap::HashMap;
struct cmplx {
re: f64,
@ -125,7 +125,7 @@ fn writer(path: ~str, pport: comm::Port<Line>, size: uint)
};
cout.write_line("P4");
cout.write_line(fmt!("%u %u", size, size));
let mut lines: LinearMap<uint, Line> = LinearMap::new();
let mut lines: HashMap<uint, Line> = HashMap::new();
let mut done = 0_u;
let mut i = 0_u;
while i < size {

View file

@ -10,11 +10,11 @@
//buggy.rs
use core::hashmap::LinearMap;
use core::hashmap::HashMap;
fn main() {
let mut buggy_map :LinearMap<uint, &uint> =
LinearMap::new::<uint, &uint>();
let mut buggy_map :HashMap<uint, &uint> =
HashMap::new::<uint, &uint>();
buggy_map.insert(42, &*~1); //~ ERROR illegal borrow
// but it is ok if we use a temporary

View file

@ -8,10 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use core::hashmap::LinearSet;
use core::hashmap::HashSet;
struct Foo {
n: LinearSet<int>,
n: HashSet<int>,
}
pub impl Foo {
@ -29,6 +29,6 @@ fn bar(f: &mut Foo) {
}
fn main() {
let mut f = Foo { n: LinearSet::new() };
let mut f = Foo { n: HashSet::new() };
bar(&mut f);
}

View file

@ -11,10 +11,10 @@
// error-pattern: mismatched types
extern mod std;
use std::bitv;
use core::hashmap::LinearMap;
use core::hashmap::HashMap;
struct FnInfo {
vars: LinearMap<uint, VarInfo>
vars: HashMap<uint, VarInfo>
}
struct VarInfo {

View file

@ -9,12 +9,12 @@
// except according to those terms.
use core::container::Map;
use core::hashmap::LinearMap;
use core::hashmap::HashMap;
// Test that trait types printed in error msgs include the type arguments.
fn main() {
let x: @Map<~str, ~str> = @LinearMap::new::<~str, ~str>() as
let x: @Map<~str, ~str> = @HashMap::new::<~str, ~str>() as
@Map<~str, ~str>;
let y: @Map<uint, ~str> = @x;
//~^ ERROR mismatched types: expected `@core::container::Map<uint,~str>`

View file

@ -14,7 +14,7 @@
fn main() {
let count = @mut 0u;
let mut map = core::hashmap::LinearMap::new();
let mut map = core::hashmap::HashMap::new();
let mut arr = ~[];
for uint::range(0u, 10u) |i| {
arr += ~[@~"key stuff"];

View file

@ -20,17 +20,17 @@ type EqFn<K> = ~fn(K, K) -> bool;
struct LM { resize_at: uint, size: uint }
enum LinearMap<K,V> {
LinearMap_(LM)
enum HashMap<K,V> {
HashMap_(LM)
}
fn linear_map<K,V>() -> LinearMap<K,V> {
LinearMap_(LM{
fn linear_map<K,V>() -> HashMap<K,V> {
HashMap_(LM{
resize_at: 32,
size: 0})
}
pub impl<K,V> LinearMap<K,V> {
pub impl<K,V> HashMap<K,V> {
fn len(&mut self) -> uint {
self.size
}

View file

@ -19,7 +19,7 @@
pub fn map(filename: ~str, emit: map_reduce::putter) { emit(filename, ~"1"); }
mod map_reduce {
use core::hashmap::LinearMap;
use core::hashmap::HashMap;
use core::comm::*;
pub type putter = @fn(~str, ~str);
@ -37,9 +37,9 @@ mod map_reduce {
}
fn map_task(ctrl: SharedChan<ctrl_proto>, input: ~str) {
let intermediates = @mut LinearMap::new();
let intermediates = @mut HashMap::new();
fn emit(im: &mut LinearMap<~str, int>, ctrl: SharedChan<ctrl_proto>, key: ~str,
fn emit(im: &mut HashMap<~str, int>, ctrl: SharedChan<ctrl_proto>, key: ~str,
_val: ~str) {
if im.contains_key(&key) {
return;
@ -65,9 +65,9 @@ mod map_reduce {
// This task becomes the master control task. It spawns others
// to do the rest.
let mut reducers: LinearMap<~str, int>;
let mut reducers: HashMap<~str, int>;
reducers = LinearMap::new();
reducers = HashMap::new();
start_mappers(ctrl_chan, inputs.clone());

View file

@ -10,10 +10,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use core::hashmap::LinearMap;
use core::hashmap::HashMap;
pub fn main() {
let mut m = LinearMap::new();
let mut m = HashMap::new();
m.insert(str::to_bytes(~"foo"), str::to_bytes(~"bar"));
error!(m);
}

View file

@ -14,11 +14,11 @@
extern mod req;
use req::*;
use core::hashmap::LinearMap;
use core::hashmap::HashMap;
pub fn main() {
let v = ~[@~"hi"];
let mut m: req::header_map = LinearMap::new();
let mut m: req::header_map = HashMap::new();
m.insert(~"METHOD", @mut v);
request::<int>(&m);
}

View file

@ -13,9 +13,9 @@
// Minimized version of issue-2804.rs. Both check that callee IDs don't
// clobber the previous node ID in a macro expr
use core::hashmap::LinearMap;
use core::hashmap::HashMap;
fn add_interfaces(managed_ip: ~str, device: LinearMap<~str, int>) {
fn add_interfaces(managed_ip: ~str, device: HashMap<~str, int>) {
error!("%s, %?", managed_ip, device.get(&~"interfaces"));
}

View file

@ -11,7 +11,7 @@
// except according to those terms.
extern mod std;
use core::hashmap::LinearMap;
use core::hashmap::HashMap;
use std::json;
enum object {
@ -58,7 +58,7 @@ fn add_interface(store: int, managed_ip: ~str, data: std::json::Json) -> (~str,
}
}
fn add_interfaces(store: int, managed_ip: ~str, device: LinearMap<~str, std::json::Json>) -> ~[(~str, object)]
fn add_interfaces(store: int, managed_ip: ~str, device: HashMap<~str, std::json::Json>) -> ~[(~str, object)]
{
match device.get(&~"interfaces")
{

View file

@ -10,10 +10,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use core::hashmap::LinearMap;
use core::hashmap::HashMap;
pub fn main() {
let mut buggy_map: LinearMap<uint, &uint> = LinearMap::new::<uint, &uint>();
let mut buggy_map: HashMap<uint, &uint> = HashMap::new::<uint, &uint>();
let x = ~1;
buggy_map.insert(42, &*x);
}

View file

@ -29,7 +29,7 @@ fn check_strs(actual: &str, expected: &str) -> bool
#[test]
fn tester()
{
let mut table = core::hashmap::LinearMap();
let mut table = core::hashmap::HashMap();
table.insert(@~"one", 1);
table.insert(@~"two", 2);
assert!(check_strs(table.to_str(), ~"xxx")); // not sure what expected should be

View file

@ -8,9 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use core::hashmap::LinearMap;
use core::hashmap::HashMap;
pub fn main() {
let mut x = LinearMap::new();
let mut x = HashMap::new();
x.insert((@"abc", 0), 0);
}