Changeset 1725
- Timestamp:
- 07/04/10 22:09:03 (14 years ago)
- Files:
-
- trunk/phobos/std/algorithm.d (modified) (3 diffs)
- trunk/phobos/std/array.d (modified) (1 diff)
- trunk/phobos/std/boxer.d (modified) (1 diff)
- trunk/phobos/std/concurrency.d (modified) (1 diff)
- trunk/phobos/std/date.d (modified) (1 diff)
- trunk/phobos/std/demangle.d (modified) (1 diff)
- trunk/phobos/std/file.d (modified) (1 diff)
- trunk/phobos/std/format.d (modified) (1 diff)
- trunk/phobos/std/functional.d (modified) (1 diff)
- trunk/phobos/std/getopt.d (modified) (1 diff)
- trunk/phobos/std/md5.d (modified) (1 diff)
- trunk/phobos/std/process.d (modified) (1 diff)
- trunk/phobos/std/random.d (modified) (1 diff)
- trunk/phobos/std/range.d (modified) (1 diff)
- trunk/phobos/std/stdio.d (modified) (1 diff)
- trunk/phobos/std/string.d (modified) (1 diff)
- trunk/phobos/std/typecons.d (modified) (1 diff)
- trunk/phobos/std/uri.d (modified) (1 diff)
- trunk/phobos/std/utf.d (modified) (1 diff)
- trunk/phobos/std/variant.d (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/phobos/std/algorithm.d
r1718 r1725 39 39 40 40 Copyright: Andrei Alexandrescu 2008-. 41 41 42 42 License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0). 43 43 44 44 Authors: $(WEB erdani.com, Andrei Alexandrescu) 45 45 */ 46 46 module std.algorithm; 47 47 48 48 import std.c.string; 49 import std.array, std.container, std.con tracts, std.conv, std.date,49 import std.array, std.container, std.conv, std.date, std.exception, 50 50 std.functional, std.math, std.metastrings, std.range, std.string, 51 51 std.traits, std.typecons, std.typetuple; 52 52 53 53 version(unittest) 54 54 { 55 55 import std.random, std.stdio, std.string; 56 56 mixin(dummyRanges); 57 57 } 58 58 59 59 /** … … 769 769 { 770 770 int[] a = [ 1, 2, 3, 4, 5 ]; 771 771 int[] b = new int[3]; 772 772 assert(moveSome(a, b).field[0] is a[3 .. $]); 773 773 assert(a[0 .. 3] == b); 774 774 assert(a == [ 1, 2, 3, 4, 5 ]); 775 775 } 776 776 777 777 // swap 778 778 /** 779 Swaps $(D lhs) and $(D rhs). See also $(XREF contracts, pointsTo).779 Swaps $(D lhs) and $(D rhs). See also $(XREF exception, pointsTo). 780 780 781 781 Preconditions: 782 782 783 783 $(D !pointsTo(lhs, lhs) && !pointsTo(lhs, rhs) && !pointsTo(rhs, lhs) 784 784 && !pointsTo(rhs, rhs)) 785 785 */ 786 786 void swap(T)(ref T a, ref T b) if (!is(typeof(T.init.proxySwap(T.init)))) 787 787 { 788 788 static if (is(T == struct)) 789 789 { … … 1639 1639 1640 1640 The default predicate for $(D find), which is $(D "a == b"), and the 1641 1641 default predicate for $(D assumeSorted), which is $(D "a < b"), 1642 1642 already satisfy the relation. 1643 1643 1644 1644 If the above condition is satisfied, only $(BIGOH 1645 1645 log(haystack.length)) steps are needed to position $(D haystack) at 1646 1646 the beginning of the search. Also, once positioned, the search will 1647 1647 continue only as long as haystack and the needle start with equal 1648 1648 elements. To inform $(D find) that you want to perform a binary 1649 search, wrap $(D haystack) with a call to $(XREF contracts,1649 search, wrap $(D haystack) with a call to $(XREF exception, 1650 1650 assumeSorted). Then $(D find) will assume that $(D pred) and $(D less) 1651 1651 are in the right relation and also that $(D haystack) is already 1652 1652 sorted by $(D less). 1653 1653 1654 1654 Example: 1655 1655 ---- 1656 1656 int[] a = [ -1, 0, 1, 2, 3, 4, 5 ]; 1657 1657 assert(find(assumeSorted(a), 3) == [ 3, 4, 5 ]); 1658 1658 assert(find(assumeSorted(a), [3, 4]) == [ 3, 4, 5 ]); 1659 1659 assert(find(assumeSorted(a), [3, 5], [1, 3], 8).empty); trunk/phobos/std/array.d
r1715 r1725 7 7 8 8 Copyright Andrei Alexandrescu 2008 - 2009. 9 9 Distributed under the Boost Software License, Version 1.0. 10 10 (See accompanying file LICENSE_1_0.txt or copy at 11 11 http://www.boost.org/LICENSE_1_0.txt) 12 12 */ 13 13 module std.array; 14 14 15 15 import std.c.stdio; 16 16 import core.memory; 17 import std.algorithm, std.con tracts, std.conv, std.encoding, std.range,17 import std.algorithm, std.conv, std.encoding, std.exception, std.range, 18 18 std.string, std.traits, std.typecons, std.utf; 19 19 version(unittest) private import std.stdio; 20 20 21 21 /** 22 22 Returns a newly-allocated array consisting of a copy of the input 23 23 range $(D r). 24 24 25 25 Example: 26 26 27 27 ---- trunk/phobos/std/boxer.d
r1343 r1725 71 71 * Copyright Burton Radons 2007 - 2009. 72 72 * Distributed under the Boost Software License, Version 1.0. 73 73 * (See accompanying file LICENSE_1_0.txt or copy at 74 74 * http://www.boost.org/LICENSE_1_0.txt) 75 75 */ 76 76 module std.boxer; 77 77 78 78 private import std.format; 79 79 private import std.string; 80 80 private import std.utf; 81 import std. contracts;81 import std.exception; 82 82 83 83 /* These functions and types allow packing objects into generic containers 84 84 * and recovering them later. This comes into play in a wide spectrum of 85 85 * utilities, such as with a scripting language, or as additional user data 86 86 * for an object. 87 87 * 88 88 * Box an object by calling the box function: 89 89 * 90 90 * Box x = box(4); 91 91 * trunk/phobos/std/concurrency.d
r1710 r1725 32 32 import core.sync.rwmutex; 33 33 import core.sync.semaphore; 34 34 import std.variant; 35 35 } 36 36 private 37 37 { 38 38 import core.thread; 39 39 //import core.sync.condition; 40 40 //import core.sync.mutex; 41 41 import std.algorithm; 42 import std. contracts;42 import std.exception; 43 43 import std.range; 44 44 import std.stdio; 45 45 import std.range; 46 46 import std.traits; 47 47 import std.typecons; 48 48 import std.typetuple; 49 49 50 50 template isTuple(T) 51 51 { 52 52 enum isTuple = __traits(compiles, trunk/phobos/std/date.d
r1542 r1725 17 17 * 18 18 * Copyright Digital Mars 2000 - 2009. 19 19 * Distributed under the Boost Software License, Version 1.0. 20 20 * (See accompanying file LICENSE_1_0.txt or copy at 21 21 * http://www.boost.org/LICENSE_1_0.txt) 22 22 */ 23 23 module std.date; 24 24 25 25 private import std.stdio; 26 26 private import std.dateparse; 27 import std.c.stdlib, std.con tracts, std.conv;27 import std.c.stdlib, std.conv, std.exception; 28 28 29 29 /** 30 30 * $(D d_time) is a signed arithmetic type giving the time elapsed 31 31 * since January 1, 1970. Negative values are for dates preceding 32 32 * 1970. The time unit used is Ticks. Ticks are milliseconds or 33 33 * smaller intervals. 34 34 * 35 35 * The usual arithmetic operations can be performed on d_time, such as adding, 36 36 * subtracting, etc. Elapsed time in Ticks can be computed by subtracting a 37 37 * starting d_time from an ending d_time. trunk/phobos/std/demangle.d
r1390 r1725 17 17 * http://www.boost.org/LICENSE_1_0.txt) 18 18 */ 19 19 module std.demangle; 20 20 21 21 //debug=demangle; // uncomment to turn on debugging printf's 22 22 23 23 private import std.ctype; 24 24 private import std.string; 25 25 import std.conv; 26 26 private import std.utf; 27 import std. contracts;27 import std.exception; 28 28 29 29 private import std.stdio; 30 30 31 31 private class MangleException : Exception 32 32 { 33 33 this() 34 34 { 35 35 super("MangleException"); 36 36 } 37 37 } trunk/phobos/std/file.d
r1708 r1725 13 13 14 14 Copyright Digital Mars 2007 - 2009. 15 15 Distributed under the Boost Software License, Version 1.0. 16 16 (See accompanying file LICENSE_1_0.txt or copy at 17 17 http://www.boost.org/LICENSE_1_0.txt) 18 18 */ 19 19 module std.file; 20 20 21 21 import core.memory; 22 22 import core.stdc.stdio, core.stdc.stdlib, core.stdc.string, 23 core.stdc.errno, std.algorithm, std.array, 24 std.con tracts, std.conv, std.date, std.format, std.path, std.process,23 core.stdc.errno, std.algorithm, std.array, 24 std.conv, std.date, std.exception, std.format, std.path, std.process, 25 25 std.range, std.regexp, std.stdio, std.string, std.traits, std.typecons, 26 26 std.typetuple, std.utf; 27 27 version (Win32) 28 28 { 29 29 import core.sys.windows.windows, std.windows.charset, 30 30 std.windows.syserror, std.__fileinit; 31 31 /* 32 32 * Since Win 9x does not support the "W" API's, first convert 33 33 * to wchar, then convert to multibyte using the current code 34 34 * page. trunk/phobos/std/format.d
r1719 r1725 11 11 * License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0). 12 12 * 13 13 * Authors: $(WEB digitalmars.com, Walter Bright), $(WEB 14 14 * erdani.com, Andrei Alexandrescu) 15 15 */ 16 16 module std.format; 17 17 18 18 //debug=format; // uncomment to turn on debugging printf's 19 19 20 20 import core.stdc.stdio, core.stdc.stdlib, core.stdc.string; 21 import std.algorithm, std.array, std.bitmanip, std.con tracts, std.conv,22 std.ctype, std. functional, std.range, std.stdarg, std.string, std.system,23 std. traits, std.typetuple, std.utf;21 import std.algorithm, std.array, std.bitmanip, std.conv, 22 std.ctype, std.exception, std.functional, std.range, std.stdarg, 23 std.string, std.system, std.traits, std.typetuple, std.utf; 24 24 version(unittest) { 25 25 import std.stdio, std.typecons; 26 26 } 27 27 28 28 version (Windows) version (DigitalMars) 29 29 { 30 30 version = DigitalMarsC; 31 31 } 32 32 33 33 version (DigitalMarsC) trunk/phobos/std/functional.d
r1657 r1725 13 13 14 14 Copyright Andrei Alexandrescu 2008 - 2009. 15 15 Distributed under the Boost Software License, Version 1.0. 16 16 (See accompanying file LICENSE_1_0.txt or copy at 17 17 http://www.boost.org/LICENSE_1_0.txt) 18 18 */ 19 19 module std.functional; 20 20 21 21 import std.metastrings, std.stdio, std.traits, std.typecons, std.typetuple; 22 22 // for making various functions visible in *naryFun 23 import std.algorithm, std.con tracts, std.conv, std.math, std.range, std.string;23 import std.algorithm, std.conv, std.exception, std.math, std.range, std.string; 24 24 25 25 /** 26 26 Transforms a string representing an expression into a unary 27 27 function. The string must use symbol name $(D a) as the parameter. 28 28 29 29 Example: 30 30 31 31 ---- 32 32 alias unaryFun!("(a & 1) == 0") isEven; 33 33 assert(isEven(2) && !isEven(1)); trunk/phobos/std/getopt.d
r1559 r1725 23 23 getopt) infers the expected parameter types from the static types of 24 24 the passed-in pointers. 25 25 26 26 Copyright Andrei Alexandrescu 2008 - 2009. 27 27 Distributed under the Boost Software License, Version 1.0. 28 28 (See accompanying file LICENSE_1_0.txt or copy at 29 29 http://www.boost.org/LICENSE_1_0.txt) 30 30 */ 31 31 module std.getopt; 32 32 33 private import std.string, std.conv, std.traits, std. contracts, std.bitmanip,34 std.algorithm, std.ctype ;33 private import std.string, std.conv, std.traits, std.bitmanip, 34 std.algorithm, std.ctype, std.exception; 35 35 36 36 //version (unittest) 37 37 //{ 38 38 import std.stdio; // for testing only 39 39 //} 40 40 41 41 /** 42 42 Synopsis: 43 43 44 44 --------- trunk/phobos/std/md5.d
r1390 r1725 80 80 without express or implied warranty of any kind. 81 81 These notices must be retained in any copies of any part of this 82 82 documentation and/or software. 83 83 */ 84 84 85 85 module std.md5; 86 86 87 87 //debug=md5; // uncomment to turn on debugging printf's 88 88 89 89 import std.string; 90 import std. contracts;90 import std.exception; 91 91 import std.c.stdio : printf; 92 92 93 93 /*************************************** 94 94 * Computes MD5 digest of several arrays of data. 95 95 */ 96 96 97 97 void sum(ref ubyte[16] digest, in void[][] data...) 98 98 { 99 99 MD5_CTX context; 100 100 context.start(); trunk/phobos/std/process.d
r1500 r1725 21 21 http://www.boost.org/LICENSE_1_0.txt) 22 22 */ 23 23 module std.process; 24 24 25 25 private import std.c.stdlib; 26 26 private import std.c.string; 27 27 private import std.conv; 28 28 private import std.string; 29 29 private import std.c.process; 30 30 private import core.stdc.errno; 31 private import std. contracts;31 private import std.exception; 32 32 version (Windows) 33 33 { 34 34 import std.array, std.format, std.random, std.file; 35 35 private import std.stdio : readln, fclose; 36 36 private import std.c.windows.windows:GetCurrentProcessId; 37 37 } 38 38 version (Posix) 39 39 { 40 40 private import std.stdio; 41 41 } trunk/phobos/std/random.d
r1656 r1725 47 47 random number facility proposed by Jens Maurer and contributed to by 48 48 researchers at the Fermi laboratory. 49 49 50 50 Copyright Andrei Alexandrescu 2008 - 2009. 51 51 Distributed under the Boost Software License, Version 1.0. 52 52 (See accompanying file LICENSE_1_0.txt or copy at 53 53 http://www.boost.org/LICENSE_1_0.txt) 54 54 */ 55 55 module std.random; 56 56 57 import std.algorithm, std.c.time, std.con tracts, std.conv, std.date, std.math,57 import std.algorithm, std.c.time, std.conv, std.date, std.exception, std.math, 58 58 std.numeric, std.process, std.range, std.stdio, std.traits, core.thread; 59 59 60 60 // Segments of the code in this file Copyright (c) 1997 by Rick Booth 61 61 // From "Inner Loops" by Rick Booth, Addison-Wesley 62 62 63 63 // Work derived from: 64 64 65 65 /* 66 66 A C-program for MT19937, with initialization improved 2002/1/26. 67 67 Coded by Takuji Nishimura and Makoto Matsumoto. trunk/phobos/std/range.d
r1720 r1725 9 9 10 10 WIKI = Phobos/StdRange 11 11 12 12 Copyright: Copyright Andrei Alexandrescu 2008-. 13 13 License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0). 14 14 Authors: $(WEB erdani.org, Andrei Alexandrescu) 15 15 */ 16 16 module std.range; 17 17 18 18 public import std.array; 19 import std. contracts;19 import std.exception; 20 20 import std.traits; 21 21 import std.typecons; 22 22 import std.typetuple; 23 23 import std.algorithm; 24 24 import std.functional; 25 25 import std.conv; 26 26 27 27 // For testing only. This code is included in a string literal to be included 28 28 // in whatever module it's needed in, so that each module that uses it can be 29 29 // tested individually, without needing to link to std.range. trunk/phobos/std/stdio.d
r1721 r1725 11 11 License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0). 12 12 Authors: $(WEB digitalmars.com, Walter Bright), 13 13 $(WEB erdani.org, Andrei Alexandrescu) 14 14 */ 15 15 module std.stdio; 16 16 17 17 public import core.stdc.stdio; 18 18 import std.stdiobase; 19 19 import core.memory, core.stdc.errno, core.stdc.stddef, core.stdc.stdlib, 20 20 core.stdc.string, core.stdc.wchar_; 21 import std.algorithm, std.array, std.con tracts, std.conv, std.file, std.format,21 import std.algorithm, std.array, std.conv, std.exception, std.file, std.format, 22 22 std.range, std.string, std.traits, std.typecons, 23 23 std.typetuple, std.utf; 24 24 25 25 version (DigitalMars) version (Windows) 26 26 { 27 27 // Specific to the way Digital Mars C does stdio 28 28 version = DIGITAL_MARS_STDIO; 29 29 import std.c.stdio : __fhnd_info, FHND_WCHAR, FHND_TEXT; 30 30 } 31 31 trunk/phobos/std/string.d
r1646 r1725 20 20 Distributed under the Boost Software License, Version 1.0. 21 21 (See accompanying file LICENSE_1_0.txt or copy at 22 22 http://www.boost.org/LICENSE_1_0.txt) 23 23 */ 24 24 module std.string; 25 25 26 26 //debug=string; // uncomment to turn on debugging printf's 27 27 28 28 private import core.exception : onRangeError; 29 29 import core.stdc.stdio, core.stdc.stdlib, 30 core.stdc.string, std.algorithm, std.array, 31 std.con tracts, std.conv, std.ctype, std.encoding, std.format,30 core.stdc.string, std.algorithm, std.array, 31 std.conv, std.ctype, std.encoding, std.exception, std.format, 32 32 std.metastrings, std.range, std.regex, std.stdarg, std.stdio, std.traits, 33 33 std.typetuple, std.uni, std.utf; 34 34 35 35 public import std.algorithm : startsWith, endsWith; 36 36 37 37 version(Windows) extern (C) 38 38 { 39 39 size_t wcslen(in wchar *); 40 40 int wcscmp(in wchar *, in wchar *); 41 41 } trunk/phobos/std/typecons.d
r1723 r1725 44 44 ---- 45 45 46 46 Copyright: Copyright the respective authors, 2008- 47 47 License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0). 48 48 Authors: $(WEB erdani.org, Andrei Alexandrescu), 49 49 $(WEB bartoszmilewski.wordpress.com, Bartosz Milewski), 50 50 Don Clugston, 51 51 Shin Fujishiro 52 52 */ 53 53 module std.typecons; 54 import core.stdc.stdlib, std.algorithm, std.array, std.con tracts, std.conv,55 std. metastrings, std.traits, std.typetuple, core.memory;54 import core.stdc.stdlib, std.algorithm, std.array, std.conv, 55 std.exception, std.metastrings, std.traits, std.typetuple, core.memory; 56 56 version(unittest) import std.stdio; 57 57 58 58 /** 59 59 Encapsulates unique ownership of a resource. Resource of type T is 60 60 deleted at the end of the scope, unless it is transferred. The 61 61 transfer can be explicit, by calling $(D release), or implicit, when 62 62 returning Unique from a function. The resource can be a polymorphic 63 63 class object, in which case Unique behaves polymorphically too. 64 64 65 65 Example: trunk/phobos/std/uri.d
r1500 r1725 26 26 module std.uri; 27 27 28 28 //debug=uri; // uncomment to turn on debugging printf's 29 29 30 30 /* ====================== URI Functions ================ */ 31 31 32 32 private import std.ctype; 33 33 private import std.c.stdlib; 34 34 private import std.utf; 35 35 private import std.stdio; 36 import std. contracts;36 import std.exception; 37 37 38 38 class URIerror : Error 39 39 { 40 40 this() 41 41 { 42 42 super("URI error"); 43 43 } 44 44 } 45 45 46 46 enum trunk/phobos/std/utf.d
r1684 r1725 21 21 * License: <a href="http://www.boost.org/LICENSE_1_0.txt">Boost License 1.0</a>. 22 22 * Authors: $(WEB digitalmars.com, Walter Bright) 23 23 * 24 24 * Copyright Digital Mars 2000 - 2009. 25 25 * Distributed under the Boost Software License, Version 1.0. 26 26 * (See accompanying file LICENSE_1_0.txt or copy at 27 27 * http://www.boost.org/LICENSE_1_0.txt) 28 28 */ 29 29 module std.utf; 30 30 31 import std.con tracts, std.conv, std.range, std.traits, std.typecons;31 import std.conv, std.exception, std.range, std.traits, std.typecons; 32 32 33 33 //debug=utf; // uncomment to turn on debugging printf's 34 34 35 35 debug (utf) import core.stdc.stdio : printf; 36 36 37 37 deprecated class UtfError : Error 38 38 { 39 39 size_t idx; // index in string of where error occurred 40 40 41 41 this(string s, size_t i) trunk/phobos/std/variant.d
r1666 r1725 49 49 * Credits: 50 50 * 51 51 * Reviewed by Brad Roberts. Daniel Keep provided a detailed code 52 52 * review prompting the following improvements: (1) better support for 53 53 * arrays; (2) support for associative arrays; (3) friendlier behavior 54 54 * towards the garbage collector. 55 55 * 56 56 * Copyright: Copyright Andrei Alexandrescu 2007 - 2009. 57 57 * License: <a href="http://www.boost.org/LICENSE_1_0.txt">Boost License 1.0</a>. 58 58 * Authors: $(WEB erdani.org, Andrei Alexandrescu) 59 * Credits: Brad Roberts came up with the name $(D_PARAM contracts).60 59 * 61 60 * Copyright Andrei Alexandrescu 2007 - 2009. 62 61 * Distributed under the Boost Software License, Version 1.0. 63 62 * (See accompanying file LICENSE_1_0.txt or copy at 64 63 * http://www.boost.org/LICENSE_1_0.txt) 65 64 */ 66 65 module std.variant; 67 66 68 67 import std.traits, std.c.string, std.typetuple, std.conv; 69 68 version(unittest) 70 69 { 71 import std. contracts, std.stdio;70 import std.exception, std.stdio; 72 71 } 73 72 74 73 private template maxSize(T...) 75 74 { 76 75 static if (T.length == 1) 77 76 { 78 77 enum size_t maxSize = T[0].sizeof; 79 78 } 80 79 else 81 80 {
