Skip to content

Commit 1923158

Browse files
committed
---
yaml --- r: 71934 b: refs/heads/dist-snap c: b3b8c05 h: refs/heads/master v: v3
1 parent 574f468 commit 1923158

File tree

20 files changed

+1751
-177
lines changed

20 files changed

+1751
-177
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
99
refs/heads/incoming: b50030718cf28f2a5a81857a26b57442734fe854
10-
refs/heads/dist-snap: 61b29993ddd531c6f53f7d21ddf28d26d4d63a21
10+
refs/heads/dist-snap: b3b8c0502bb7d223b4da50f3eac2c1ad51cf6c72
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1313
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/configure

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,7 @@ do
859859
LDFLAGS=$LLVM_LDFLAGS
860860

861861
LLVM_FLAGS="$LLVM_TARGETS $LLVM_OPTS $LLVM_BUILD \
862-
$LLVM_HOST $LLVM_TARGET"
862+
$LLVM_HOST $LLVM_TARGET --with-python=$CFG_PYTHON"
863863

864864
msg "configuring LLVM with:"
865865
msg "$LLVM_FLAGS"

branches/dist-snap/src/libcore/rand.rs

Lines changed: 183 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,21 @@ pub struct Weighted<T> {
150150

151151
pub trait RngUtil {
152152
fn gen<T:Rand>(&self) -> T;
153-
/// Return a random int
153+
/**
154+
* Return a random int
155+
*
156+
* *Example*
157+
*
158+
* ~~~
159+
*
160+
* use core::rand::RngUtil;
161+
*
162+
* fn main() {
163+
* rng = rand::Rng();
164+
* println(fmt!("%d",rng.gen_int()));
165+
* }
166+
* ~~~
167+
*/
154168
fn gen_int(&self) -> int;
155169
fn gen_int_range(&self, start: int, end: int) -> int;
156170
/// Return a random i8
@@ -176,7 +190,21 @@ pub trait RngUtil {
176190
fn gen_u32(&self) -> u32;
177191
/// Return a random u64
178192
fn gen_u64(&self) -> u64;
179-
/// Return a random float in the interval [0,1]
193+
/**
194+
* Return random float in the interval [0,1]
195+
*
196+
* *Example*
197+
*
198+
* ~~~
199+
*
200+
* use core::rand::RngUtil;
201+
*
202+
* fn main() {
203+
* rng = rand::Rng();
204+
* println(fmt!("%f",rng.gen_float()));
205+
* }
206+
* ~~~
207+
*/
180208
fn gen_float(&self) -> float;
181209
/// Return a random f32 in the interval [0,1]
182210
fn gen_f32(&self) -> f32;
@@ -188,38 +216,184 @@ pub trait RngUtil {
188216
* Return a char randomly chosen from chars, failing if chars is empty
189217
*/
190218
fn gen_char_from(&self, chars: &str) -> char;
191-
/// Return a random bool
219+
/**
220+
* Return a random bool
221+
*
222+
* *Example*
223+
*
224+
* ~~~
225+
*
226+
* use core::rand::RngUtil;
227+
*
228+
* fn main() {
229+
* rng = rand::Rng();
230+
* println(fmt!("%b",rng.gen_bool()));
231+
* }
232+
* ~~~
233+
*/
192234
fn gen_bool(&self) -> bool;
193-
/// Return a bool with a 1 in n chance of true
235+
/**
236+
* Return a bool with a 1 in n chance of true
237+
*
238+
* *Example*
239+
*
240+
* ~~~
241+
*
242+
* use core::rand::RngUtil;
243+
*
244+
* fn main() {
245+
* rng = rand::Rng();
246+
* println(fmt!("%b",rng.gen_weighted_bool(3)));
247+
* }
248+
* ~~~
249+
*/
194250
fn gen_weighted_bool(&self, n: uint) -> bool;
195251
/**
196252
* Return a random string of the specified length composed of A-Z,a-z,0-9
253+
*
254+
* *Example*
255+
*
256+
* ~~~
257+
*
258+
* use core::rand::RngUtil;
259+
*
260+
* fn main() {
261+
* rng = rand::Rng();
262+
* println(rng.gen_str(8));
263+
* }
264+
* ~~~
197265
*/
198266
fn gen_str(&self, len: uint) -> ~str;
199-
/// Return a random byte string of the specified length
267+
/**
268+
* Return a random byte string of the specified length
269+
*
270+
* *Example*
271+
*
272+
* ~~~
273+
*
274+
* use core::rand::RngUtil;
275+
*
276+
* fn main() {
277+
* rng = rand::Rng();
278+
* println(fmt!("%?",rng.gen_bytes(8)));
279+
* }
280+
* ~~~
281+
*/
200282
fn gen_bytes(&self, len: uint) -> ~[u8];
201-
/// Choose an item randomly, failing if values is empty
283+
///
284+
/**
285+
* Choose an item randomly, failing if values is empty
286+
*
287+
* *Example*
288+
*
289+
* ~~~
290+
*
291+
* use core::rand::RngUtil;
292+
*
293+
* fn main() {
294+
* rng = rand::Rng();
295+
* println(fmt!("%d",rng.choose([1,2,4,8,16,32])));
296+
* }
297+
* ~~~
298+
*/
202299
fn choose<T:Copy>(&self, values: &[T]) -> T;
203300
/// Choose Some(item) randomly, returning None if values is empty
204301
fn choose_option<T:Copy>(&self, values: &[T]) -> Option<T>;
205302
/**
206303
* Choose an item respecting the relative weights, failing if the sum of
207304
* the weights is 0
305+
*
306+
* *Example*
307+
*
308+
* ~~~
309+
*
310+
* use core::rand::RngUtil;
311+
*
312+
* fn main() {
313+
* rng = rand::Rng();
314+
* let x = [rand::Weighted {weight: 4, item: 'a'},
315+
* rand::Weighted {weight: 2, item: 'b'},
316+
* rand::Weighted {weight: 2, item: 'c'}];
317+
* println(fmt!("%c",rng.choose_weighted(x)));
318+
* }
319+
* ~~~
208320
*/
209321
fn choose_weighted<T:Copy>(&self, v : &[Weighted<T>]) -> T;
210322
/**
211323
* Choose Some(item) respecting the relative weights, returning none if
212324
* the sum of the weights is 0
325+
*
326+
* *Example*
327+
*
328+
* ~~~
329+
*
330+
* use core::rand::RngUtil;
331+
*
332+
* fn main() {
333+
* rng = rand::Rng();
334+
* let x = [rand::Weighted {weight: 4, item: 'a'},
335+
* rand::Weighted {weight: 2, item: 'b'},
336+
* rand::Weighted {weight: 2, item: 'c'}];
337+
* println(fmt!("%?",rng.choose_weighted_option(x)));
338+
* }
339+
* ~~~
213340
*/
214341
fn choose_weighted_option<T:Copy>(&self, v: &[Weighted<T>]) -> Option<T>;
215342
/**
216343
* Return a vec containing copies of the items, in order, where
217344
* the weight of the item determines how many copies there are
345+
*
346+
* *Example*
347+
*
348+
* ~~~
349+
*
350+
* use core::rand::RngUtil;
351+
*
352+
* fn main() {
353+
* rng = rand::Rng();
354+
* let x = [rand::Weighted {weight: 4, item: 'a'},
355+
* rand::Weighted {weight: 2, item: 'b'},
356+
* rand::Weighted {weight: 2, item: 'c'}];
357+
* println(fmt!("%?",rng.weighted_vec(x)));
358+
* }
359+
* ~~~
218360
*/
219361
fn weighted_vec<T:Copy>(&self, v: &[Weighted<T>]) -> ~[T];
220-
/// Shuffle a vec
362+
/**
363+
* Shuffle a vec
364+
*
365+
* *Example*
366+
*
367+
* ~~~
368+
*
369+
* use core::rand::RngUtil;
370+
*
371+
* fn main() {
372+
* rng = rand::Rng();
373+
* println(fmt!("%?",rng.shuffle([1,2,3])));
374+
* }
375+
* ~~~
376+
*/
221377
fn shuffle<T:Copy>(&self, values: &[T]) -> ~[T];
222-
/// Shuffle a mutable vec in place
378+
/**
379+
* Shuffle a mutable vec in place
380+
*
381+
* *Example*
382+
*
383+
* ~~~
384+
*
385+
* use core::rand::RngUtil;
386+
*
387+
* fn main() {
388+
* rng = rand::Rng();
389+
* let mut y = [1,2,3];
390+
* rng.shuffle_mut(y);
391+
* println(fmt!("%?",y));
392+
* rng.shuffle_mut(y);
393+
* println(fmt!("%?",y));
394+
* }
395+
* ~~~
396+
*/
223397
fn shuffle_mut<T>(&self, values: &mut [T]);
224398
}
225399

@@ -337,7 +511,7 @@ impl RngUtil for @Rng {
337511
self.next() & 1u32 == 1u32
338512
}
339513

340-
/// Return a bool with a 1 in n chance of true
514+
/// Return a bool with a 1-in-n chance of true
341515
fn gen_weighted_bool(&self, n: uint) -> bool {
342516
if n == 0u {
343517
true

0 commit comments

Comments
 (0)