Skip to content

Commit ca92372

Browse files
committed
Use LaTeX in a few of the standard lib crates.
1 parent 71052f8 commit ca92372

File tree

12 files changed

+37
-37
lines changed

12 files changed

+37
-37
lines changed

src/libcollections/dlist.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,15 @@ fn link_with_prev<T>(mut next: Box<Node<T>>, prev: Rawlink<Node<T>>)
132132
impl<T> Collection for DList<T> {
133133
/// Returns `true` if the `DList` is empty.
134134
///
135-
/// This operation should compute in O(1) time.
135+
/// This operation should compute in $$O(1)$$ time.
136136
#[inline]
137137
fn is_empty(&self) -> bool {
138138
self.list_head.is_none()
139139
}
140140

141141
/// Returns the length of the `DList`.
142142
///
143-
/// This operation should compute in O(1) time.
143+
/// This operation should compute in $$O(1)$$ time.
144144
#[inline]
145145
fn len(&self) -> uint {
146146
self.length
@@ -248,15 +248,15 @@ impl<T> Deque<T> for DList<T> {
248248

249249
/// Adds an element first in the list.
250250
///
251-
/// This operation should compute in O(1) time.
251+
/// This operation should compute in $$O(1)$$ time.
252252
fn push_front(&mut self, elt: T) {
253253
self.push_front_node(box Node::new(elt))
254254
}
255255

256256
/// Removes the first element and returns it, or `None` if the list is
257257
/// empty.
258258
///
259-
/// This operation should compute in O(1) time.
259+
/// This operation should compute in $$O(1)$$ time.
260260
fn pop_front(&mut self) -> Option<T> {
261261
self.pop_front_node().map(|box Node{value, ..}| value)
262262
}
@@ -339,7 +339,7 @@ impl<T> DList<T> {
339339

340340
/// Adds all elements from `other` to the end of the list.
341341
///
342-
/// This operation should compute in O(1) time.
342+
/// This operation should compute in $$O(1)$$ time.
343343
///
344344
/// # Example
345345
///
@@ -380,7 +380,7 @@ impl<T> DList<T> {
380380

381381
/// Adds all elements from `other` to the beginning of the list.
382382
///
383-
/// This operation should compute in O(1) time.
383+
/// This operation should compute in $$O(1)$$ time.
384384
///
385385
/// # Example
386386
///
@@ -409,7 +409,7 @@ impl<T> DList<T> {
409409
/// Inserts `elt` before the first `x` in the list where `f(x, elt)` is
410410
/// true, or at the end.
411411
///
412-
/// This operation should compute in O(N) time.
412+
/// This operation should compute in $$O(N)$$ time.
413413
///
414414
/// # Example
415415
///
@@ -448,7 +448,7 @@ impl<T> DList<T> {
448448
/// Iterates both `DList`s with `a` from self and `b` from `other`, and
449449
/// put `a` in the result if `f(a, b)` is true, and otherwise `b`.
450450
///
451-
/// This operation should compute in O(max(N, M)) time.
451+
/// This operation should compute in $$O(\max(N, M))$$ time.
452452
pub fn merge(&mut self, mut other: DList<T>, f: |&T, &T| -> bool) {
453453
{
454454
let mut it = self.iter_mut();
@@ -512,7 +512,7 @@ impl<T> DList<T> {
512512
impl<T: Ord> DList<T> {
513513
/// Inserts `elt` sorted in ascending order.
514514
///
515-
/// This operation should compute in O(N) time.
515+
/// This operation should compute in $$O(N)$$ time.
516516
#[inline]
517517
pub fn insert_ordered(&mut self, elt: T) {
518518
self.insert_when(elt, |a, b| a >= b)

src/libcollections/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
1818
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
1919
html_root_url = "http://doc.rust-lang.org/master/",
20-
html_playground_url = "http://play.rust-lang.org/")]
20+
html_playground_url = "http://play.rust-lang.org/",
21+
enable_math)]
2122

2223
#![feature(macro_rules, managed_boxes, default_type_params, phase, globs)]
2324
#![feature(unsafe_destructor, import_shadowing)]

src/libcollections/priority_queue.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010

1111
//! A priority queue implemented with a binary heap.
1212
//!
13-
//! Insertions have `O(log n)` time complexity and checking or popping the largest element is
14-
//! `O(1)`. Converting a vector to a priority queue can be done in-place, and has `O(n)`
13+
//! Insertions have $$O(\log n)$$ time complexity and checking or popping the largest element is
14+
//! $$O(1)$$ . Converting a vector to a priority queue can be done in-place, and has $$O(n)$$
1515
//! complexity. A priority queue can also be converted to a sorted vector in-place, allowing it to
16-
//! be used for an `O(n log n)` in-place heapsort.
16+
//! be used for an $$O(n \log n)$$ in-place heapsort.
1717
//!
1818
//! # Example
1919
//!

src/libcollections/ringbuf.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
//! This crate implements a double-ended queue with `O(1)` amortized inserts and removals from both
12-
//! ends of the container. It also has `O(1)` indexing like a vector. The contained elements are
11+
//! This crate implements a double-ended queue with $$O(1)$$ amortized inserts and removals from both
12+
//! ends of the container. It also has $$O(1)$$ indexing like a vector. The contained elements are
1313
//! not required to be copyable, and the queue will be sendable if the contained type is sendable.
1414
//! Its interface `Deque` is defined in `collections`.
1515

src/libcollections/slice.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ pub trait MutableSliceAllocating<'a, T> {
562562
/// Sorts the slice, in place, using `compare` to compare
563563
/// elements.
564564
///
565-
/// This sort is `O(n log n)` worst-case and stable, but allocates
565+
/// This sort is $$O(n \log n)$$ worst-case and stable, but allocates
566566
/// approximately `2 * n`, where `n` is the length of `self`.
567567
///
568568
/// # Example

src/libcollections/smallintmap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
//! A simple map based on a vector for small integer keys. Space requirements
12-
//! are O(highest integer key).
12+
//! are $$O(\text{highest integer key})$$.
1313
1414
#![allow(missing_doc)]
1515

src/libcollections/string.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,7 @@ impl String {
746746
///
747747
/// # Warning
748748
///
749-
/// This is a O(n) operation as it requires copying every element in the
749+
/// This is a $$O(n)$$ operation as it requires copying every element in the
750750
/// buffer.
751751
///
752752
/// # Failure

src/libcollections/vec.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
//! A growable list type, written `Vec<T>` but pronounced 'vector.'
1212
//!
13-
//! Vectors have `O(1)` indexing, push (to the end) and pop (from the end).
13+
//! Vectors have $$O(1)$$ indexing, push (to the end) and pop (from the end).
1414
1515
use core::prelude::*;
1616

@@ -897,8 +897,8 @@ impl<T> Vec<T> {
897897

898898
/// Sorts the vector, in place, using `compare` to compare elements.
899899
///
900-
/// This sort is `O(n log n)` worst-case and stable, but allocates
901-
/// approximately `2 * n`, where `n` is the length of `self`.
900+
/// This sort is $$O(n \log n)$$ worst-case and stable, but allocates
901+
/// approximately `2 * n` elements, where `n` is the length of `self`.
902902
///
903903
/// # Example
904904
///
@@ -1006,7 +1006,7 @@ impl<T> Vec<T> {
10061006
}
10071007

10081008
/// Removes an element from anywhere in the vector and return it, replacing
1009-
/// it with the last element. This does not preserve ordering, but is O(1).
1009+
/// it with the last element. This does not preserve ordering, but is $$O(1)$$ .
10101010
///
10111011
/// Returns `None` if `index` is out of bounds.
10121012
///
@@ -1039,7 +1039,7 @@ impl<T> Vec<T> {
10391039
///
10401040
/// # Warning
10411041
///
1042-
/// This is an O(n) operation as it requires copying every element in the
1042+
/// This is an $$O(n)$$ operation as it requires copying every element in the
10431043
/// vector.
10441044
///
10451045
/// # Example
@@ -1060,7 +1060,7 @@ impl<T> Vec<T> {
10601060
///
10611061
/// # Warning
10621062
///
1063-
/// This is an O(n) operation as it requires copying every element in the
1063+
/// This is an $$O(n)$$ operation as it requires copying every element in the
10641064
/// vector.
10651065
///
10661066
/// # Example
@@ -1464,7 +1464,7 @@ impl<T> Vec<T> {
14641464
impl<T:Ord> Vec<T> {
14651465
/// Sorts the vector in place.
14661466
///
1467-
/// This sort is `O(n log n)` worst-case and stable, but allocates
1467+
/// This sort is $$O(n \log n)$$ worst-case and stable, but allocates
14681468
/// approximately `2 * n`, where `n` is the length of `self`.
14691469
///
14701470
/// # Example

src/librand/distributions/exponential.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ use distributions::{ziggurat, ziggurat_tables, Sample, IndependentSample};
1717

1818
/// A wrapper around an `f64` to generate Exp(1) random numbers.
1919
///
20-
/// See `Exp` for the general exponential distribution.Note that this
21-
// has to be unwrapped before use as an `f64` (using either
22-
/// `*` or `mem::transmute` is safe).
20+
/// See `Exp` for the general exponential distribution.
2321
///
2422
/// Implemented via the ZIGNOR variant[1] of the Ziggurat method. The
2523
/// exact description in the paper was adjusted to use tables for the
@@ -53,8 +51,8 @@ impl Rand for Exp1 {
5351

5452
/// The exponential distribution `Exp(lambda)`.
5553
///
56-
/// This distribution has density function: `f(x) = lambda *
57-
/// exp(-lambda * x)` for `x > 0`.
54+
/// This distribution has density function: $$f(x) = \lambda
55+
/// e^{-\lambda x}$$ for $$x > 0$$ .
5856
///
5957
/// # Example
6058
///

src/librand/distributions/gamma.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,11 @@ use super::{IndependentSample, Sample, Exp};
2222
///
2323
/// The density function of this distribution is
2424
///
25-
/// ```text
26-
/// f(x) = x^(k - 1) * exp(-x / θ) / (Γ(k) * θ^k)
27-
/// ```
25+
/// $$f(x) = x^{k - 1} \frac{\exp(-x / \theta)}{\Gamma(k) \theta^k}$$
2826
///
29-
/// where `Γ` is the Gamma function, `k` is the shape and `θ` is the
30-
/// scale and both `k` and `θ` are strictly positive.
27+
/// where $$\Gamma$$ is the Gamma function, $$k$$ is the shape and
28+
/// $$\theta$$ is the scale and both $$k$$ and $$\theta$$ are strictly
29+
/// positive.
3130
///
3231
/// The algorithm used is that described by Marsaglia & Tsang 2000[1],
3332
/// falling back to directly sampling from an Exponential for `shape

src/librand/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk.png",
2323
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
2424
html_root_url = "http://doc.rust-lang.org/master/",
25-
html_playground_url = "http://play.rust-lang.org/")]
25+
html_playground_url = "http://play.rust-lang.org/",
26+
enable_math)]
2627

2728
#![feature(macro_rules, phase, globs)]
2829
#![no_std]

src/libstd/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@
103103
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
104104
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
105105
html_root_url = "http://doc.rust-lang.org/master/",
106-
html_playground_url = "http://play.rust-lang.org/")]
106+
html_playground_url = "http://play.rust-lang.org/",
107+
enable_math)]
107108

108109
#![feature(macro_rules, globs, managed_boxes, linkage)]
109110
#![feature(default_type_params, phase, lang_items, unsafe_destructor)]

0 commit comments

Comments
 (0)