mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 08:44:35 +00:00
std: Camel case smallintmap
This commit is contained in:
parent
200959d7ce
commit
c491bf939e
@ -12,16 +12,16 @@ use map::map;
|
||||
|
||||
// FIXME (#2347): Should not be @; there's a bug somewhere in rustc that
|
||||
// requires this to be.
|
||||
type smallintmap_<T: copy> = {v: DVec<Option<T>>};
|
||||
type SmallIntMap_<T: copy> = {v: DVec<Option<T>>};
|
||||
|
||||
enum smallintmap<T:copy> {
|
||||
smallintmap_(@smallintmap_<T>)
|
||||
enum SmallIntMap<T:copy> {
|
||||
SmallIntMap_(@SmallIntMap_<T>)
|
||||
}
|
||||
|
||||
/// Create a smallintmap
|
||||
fn mk<T: copy>() -> smallintmap<T> {
|
||||
fn mk<T: copy>() -> SmallIntMap<T> {
|
||||
let v = DVec();
|
||||
return smallintmap_(@{v: v});
|
||||
return SmallIntMap_(@{v: v});
|
||||
}
|
||||
|
||||
/**
|
||||
@ -29,7 +29,7 @@ fn mk<T: copy>() -> smallintmap<T> {
|
||||
* the specified key then the original value is replaced.
|
||||
*/
|
||||
#[inline(always)]
|
||||
fn insert<T: copy>(self: smallintmap<T>, key: uint, +val: T) {
|
||||
fn insert<T: copy>(self: SmallIntMap<T>, key: uint, +val: T) {
|
||||
//io::println(fmt!("%?", key));
|
||||
self.v.grow_set_elt(key, None, Some(val));
|
||||
}
|
||||
@ -38,7 +38,7 @@ fn insert<T: copy>(self: smallintmap<T>, key: uint, +val: T) {
|
||||
* Get the value for the specified key. If the key does not exist
|
||||
* in the map then returns none
|
||||
*/
|
||||
pure fn find<T: copy>(self: smallintmap<T>, key: uint) -> Option<T> {
|
||||
pure fn find<T: copy>(self: SmallIntMap<T>, key: uint) -> Option<T> {
|
||||
if key < self.v.len() { return self.v.get_elt(key); }
|
||||
return None::<T>;
|
||||
}
|
||||
@ -50,7 +50,7 @@ pure fn find<T: copy>(self: smallintmap<T>, key: uint) -> Option<T> {
|
||||
*
|
||||
* If the key does not exist in the map
|
||||
*/
|
||||
pure fn get<T: copy>(self: smallintmap<T>, key: uint) -> T {
|
||||
pure fn get<T: copy>(self: SmallIntMap<T>, key: uint) -> T {
|
||||
match find(self, key) {
|
||||
None => {
|
||||
error!("smallintmap::get(): key not present");
|
||||
@ -61,12 +61,12 @@ pure fn get<T: copy>(self: smallintmap<T>, key: uint) -> T {
|
||||
}
|
||||
|
||||
/// Returns true if the map contains a value for the specified key
|
||||
fn contains_key<T: copy>(self: smallintmap<T>, key: uint) -> bool {
|
||||
fn contains_key<T: copy>(self: SmallIntMap<T>, key: uint) -> bool {
|
||||
return !option::is_none(find(self, key));
|
||||
}
|
||||
|
||||
/// Implements the map::map interface for smallintmap
|
||||
impl<V: copy> smallintmap<V>: map::map<uint, V> {
|
||||
impl<V: copy> SmallIntMap<V>: map::map<uint, V> {
|
||||
pure fn size() -> uint {
|
||||
let mut sz = 0u;
|
||||
for self.v.each |item| {
|
||||
@ -137,7 +137,7 @@ impl<V: copy> smallintmap<V>: map::map<uint, V> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<V: copy> smallintmap<V>: ops::Index<uint, V> {
|
||||
impl<V: copy> SmallIntMap<V>: ops::Index<uint, V> {
|
||||
pure fn index(&&key: uint) -> V {
|
||||
unchecked {
|
||||
get(self, key)
|
||||
@ -146,6 +146,6 @@ impl<V: copy> smallintmap<V>: ops::Index<uint, V> {
|
||||
}
|
||||
|
||||
/// Cast the given smallintmap to a map::map
|
||||
fn as_map<V: copy>(s: smallintmap<V>) -> map::map<uint, V> {
|
||||
fn as_map<V: copy>(s: SmallIntMap<V>) -> map::map<uint, V> {
|
||||
s as map::map::<uint, V>
|
||||
}
|
||||
|
@ -65,7 +65,6 @@ mod list;
|
||||
#[allow(non_camel_case_types)] // XXX
|
||||
mod map;
|
||||
mod rope;
|
||||
#[allow(non_camel_case_types)] // XXX
|
||||
mod smallintmap;
|
||||
mod sort;
|
||||
mod treemap;
|
||||
|
@ -5,7 +5,7 @@ use syntax::{ast, ast_util, visit};
|
||||
use syntax::attr;
|
||||
use syntax::codemap::span;
|
||||
use std::map::{map,hashmap,int_hash,hash_from_strs};
|
||||
use std::smallintmap::{map,smallintmap};
|
||||
use std::smallintmap::{map,SmallIntMap};
|
||||
use io::WriterUtil;
|
||||
use util::ppaux::{ty_to_str};
|
||||
use middle::pat_util::{pat_bindings};
|
||||
@ -187,7 +187,7 @@ fn get_lint_dict() -> lint_dict {
|
||||
}
|
||||
|
||||
// This is a highly not-optimal set of data structure decisions.
|
||||
type lint_modes = smallintmap<level>;
|
||||
type lint_modes = SmallIntMap<level>;
|
||||
type lint_mode_map = hashmap<ast::node_id, lint_modes>;
|
||||
|
||||
// settings_map maps node ids of items with non-default lint settings
|
||||
@ -223,7 +223,7 @@ fn get_lint_settings_level(settings: lint_settings,
|
||||
// This is kind of unfortunate. It should be somewhere else, or we should use
|
||||
// a persistent data structure...
|
||||
fn clone_lint_modes(modes: lint_modes) -> lint_modes {
|
||||
std::smallintmap::smallintmap_(@{v: copy modes.v})
|
||||
std::smallintmap::SmallIntMap_(@{v: copy modes.v})
|
||||
}
|
||||
|
||||
type ctxt_ = {dict: lint_dict,
|
||||
|
@ -640,7 +640,7 @@ type type_cache = hashmap<ast::def_id, ty_param_bounds_and_ty>;
|
||||
|
||||
type constness_cache = hashmap<ast::def_id, const_eval::constness>;
|
||||
|
||||
type node_type_table = @smallintmap::smallintmap<t>;
|
||||
type node_type_table = @smallintmap::SmallIntMap<t>;
|
||||
|
||||
fn mk_rcache() -> creader_cache {
|
||||
type val = {cnum: int, pos: uint, len: uint};
|
||||
|
@ -1,6 +1,7 @@
|
||||
use combine::combine;
|
||||
use integral::*;
|
||||
use to_str::to_str;
|
||||
use std::smallintmap::SmallIntMap;
|
||||
|
||||
enum var_value<V:copy, T:copy> {
|
||||
redirect(V),
|
||||
@ -8,7 +9,7 @@ enum var_value<V:copy, T:copy> {
|
||||
}
|
||||
|
||||
struct vals_and_bindings<V:copy, T:copy> {
|
||||
vals: smallintmap<var_value<V, T>>;
|
||||
vals: SmallIntMap<var_value<V, T>>;
|
||||
mut bindings: ~[(V, var_value<V, T>)];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user