<commit_before>// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

//! A map type
#[forbid(deprecated_mode)];

use core::cmp::Eq;
use core::hash::Hash;
use core::io::WriterUtil;
use core::io;
use core::ops;
use core::to_str::ToStr;
use core::mutable::Mut;
use core::send_map::linear::LinearMap;
use core::to_bytes::IterBytes;
use core::uint;
use core::vec;

/// A convenience type to treat a hashmap as a set
pub type Set<K:Eq IterBytes Hash> = HashMap<K, ()>;

pub type HashMap<K:Eq IterBytes Hash, V> = chained::T<K, V>;

pub trait Map<K:Eq IterBytes Hash Copy, V: Copy> {
    /// Return the number of elements in the map
    pure fn size() -> uint;

    /**
     * Add a value to the map.
     *
     * If the map already contains a value for the specified key then the
     * original value is replaced.
     *
     * Returns true if the key did not already exist in the map
     */
    fn insert(key: K, value: V) -> bool;

    /**
     * Add a value to the map.
     *
     * If the map contains a value for the key, use the function
     * to set a new value.
     */
    fn update_with_key(key: K, newval: V, ff: fn(K, V, V) -> V) -> bool;

    /**
     * Add a value to the map.
     *
     * If the map contains a value for the key, use the function to
     * set a new value.  (Like `insert_or_update_with_key`, but with a
     * function of only values.)
     */
    fn update(key: K, newval: V, ff: fn(V, V) -> V) -> bool;

    /// Returns true if the map contains a value for the specified key
    pure fn contains_key(key: K) -> bool;
<commit_msg>doc: Rename mention of insert_or_update_with_key<commit_after>// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

//! A map type
#[forbid(deprecated_mode)];

use core::cmp::Eq;
use core::hash::Hash;
use core::io::WriterUtil;
use core::io;
use core::ops;
use core::to_str::ToStr;
use core::mutable::Mut;
use core::send_map::linear::LinearMap;
use core::to_bytes::IterBytes;
use core::uint;
use core::vec;

/// A convenience type to treat a hashmap as a set
pub type Set<K:Eq IterBytes Hash> = HashMap<K, ()>;

pub type HashMap<K:Eq IterBytes Hash, V> = chained::T<K, V>;

pub trait Map<K:Eq IterBytes Hash Copy, V: Copy> {
    /// Return the number of elements in the map
    pure fn size() -> uint;

    /**
     * Add a value to the map.
     *
     * If the map already contains a value for the specified key then the
     * original value is replaced.
     *
     * Returns true if the key did not already exist in the map
     */
    fn insert(key: K, value: V) -> bool;

    /**
     * Add a value to the map.
     *
     * If the map contains a value for the key, use the function
     * to set a new value.
     */
    fn update_with_key(key: K, newval: V, ff: fn(K, V, V) -> V) -> bool;

    /**
     * Add a value to the map.
     *
     * If the map contains a value for the key, use the function to
     * set a new value.  (Like `update_with_key`, but with a
     * function of only values.)
     */
    fn update(key: K, newval: V, ff: fn(V, V) -> V) -> bool;

    /// Returns true if the map contains a value for the specified key
    pure fn contains_key(key: K) -> bool;

{'fraction_non_alphanumeric': 0.12390047750691129, 'fraction_numerical': 0.004021110831867303, 'mean_word_length': 2.823246878001921, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2834779', 'n_tokens_mistral': 1281, 'n_tokens_neox': 1258, 'n_words': 522}