about summary refs log tree commit diff
path: root/src/libextra/dlist.rs
AgeCommit message (Collapse)AuthorLines
2013-08-15std: Move the iterator param on FromIterator and Extendable to the method.Huon Wilson-5/+4
If they are on the trait then it is extremely annoying to use them as generic parameters to a function, e.g. with the iterator param on the trait itself, if one was to pass an Extendable<int> to a function that filled it either from a Range or a Map<VecIterator>, one needs to write something like: fn foo<E: Extendable<int, Range<int>> + Extendable<int, Map<&'self int, int, VecIterator<int>>> (e: &mut E, ...) { ... } since using a generic, i.e. `foo<E: Extendable<int, I>, I: Iterator<int>>` means that `foo` takes 2 type parameters, and the caller has to specify them (which doesn't work anyway, as they'll mismatch with the iterators used in `foo` itself). This patch changes it to: fn foo<E: Extendable<int>>(e: &mut E, ...) { ... }
2013-08-12auto merge of #8400 : blake2-ppc/rust/seq-ord, r=cmrbors-3/+61
Use Eq + Ord for lexicographical ordering of sequences. For each of <, <=, >= or > as R, use:: [x, ..xs] R [y, ..ys] = if x != y { x R y } else { xs R ys } Previous code using `a < b` and then `!(b < a)` for short-circuiting fails on cases such as [1.0, 2.0] < [0.0/0.0, 3.0], where the first element was effectively considered equal. Containers like &[T] did also implement only one comparison operator `<`, and derived the comparison results from this. This isn't correct either for Ord. Implement functions in `std::iterator::order::{lt,le,gt,ge,equal,cmp}` that all iterable containers can use for lexical order. We also visit tuple ordering, having the same problem and same solution (but differing implementation).
2013-08-10std: Iterator.len_ -> .lenErick Tryzelaar-4/+4
2013-08-10std: Rename Iterator.transform -> .mapErick Tryzelaar-7/+7
cc #5898
2013-08-10Mass rename of .consume{,_iter}() to .move_iter()Erick Tryzelaar-14/+14
cc #7887
2013-08-08extra::dlist: Use iterator::order for sequence orderingblake2-ppc-3/+61
2013-08-07core: option.map_consume -> option.map_moveErick Tryzelaar-10/+10
2013-08-04extra: Don't recurse in DList drop glue. #8295Brian Anderson-4/+38
The compiler-generated dtor for DList recurses deeply to drop Nodes. For big lists this can overflow the stack.
2013-08-03remove obsolete `foreach` keywordDaniel Micay-9/+9
this has been replaced by `for`
2013-08-02replace `range` with an external iteratorDaniel Micay-2/+1
2013-08-01std: Change `Times` trait to use `do` instead of `for`blake2-ppc-1/+1
Change the former repetition:: for 5.times { } to:: do 5.times { } .times() cannot be broken with `break` or `return` anymore; for those cases, use a numerical range loop instead.
2013-08-01migrate many `for` loops to `foreach`Daniel Micay-8/+8
2013-07-30extra: Implement iterator::Extendableblake2-ppc-2/+8
2013-07-29std: Rename Iterator adaptor types to drop the -Iterator suffixblake2-ppc-4/+4
Drop the "Iterator" suffix for the the structs in std::iterator. Filter, Zip, Chain etc. are shorter type names for when iterator pipelines need their types written out in full in return value types, so it's easier to read and write. the iterator module already forms enough namespace.
2013-07-27Remove dummy type parameters from iterator adaptorsblake2-ppc-4/+3
With the recent fixes to method resolution, we can now remove the dummy type parameters used as crutches in the iterator module. For example, the zip adaptor type is just ZipIterator<T, U> now.
2013-07-23dlist: Rename rotate methods to .rotate_forward() and .rotate_backward()blake2-ppc-15/+15
2013-07-22dlist: Fix .peek_next() w.r.t double ended iteratorsblake2-ppc-1/+6
.peek_next() needs to check the element counter just like the .next() and .next_back() iterators do. Also clarify .insert_next() doc w.r.t double ended iteration.
2013-07-21dlist: Remove extraneous unwrap in .pop_back_node()blake2-ppc-3/+3
2013-07-21dlist: Use Ord for .insert_ordered()blake2-ppc-3/+2
We don't need TotalOrd for ordered insertion, just the normal sort order Ord.
2013-07-21dlist: Remove bench tests for vecblake2-ppc-37/+1
These tests for ~[] performance don't really belong here, they were for comparison.
2013-07-21dlist: Add bench test for rotate_to_{front, back}blake2-ppc-0/+19
2013-07-21dlist: Add .rotate_to_front(), .rotate_to_back()blake2-ppc-0/+43
Add methods to move back element to front or front element to back, without reallocating nodes.
2013-07-21dlist: Factor out pop and push operations by list nodeblake2-ppc-54/+104
Factor out internal methods for pop/push ~Node<T>, This allows moving nodes instead of destructuring and allocating new. Make use of this in .merge() so that it requires no allocations when merging two DList.
2013-07-21dlist: Simplify match clauses to use Option methodsblake2-ppc-65/+33
Make the core Deque implementation a bit simpler by using Option methods when we simply map on a Some value, and deduplicate some common lines.
2013-07-20dlist: Implement Clone for immutable iteratorsblake2-ppc-0/+23
2013-07-20Use Option .take() or .take_unwrap() instead of util::replace where possibleblake2-ppc-1/+1
2013-07-17librustc: Remove all uses of "copy".Patrick Walton-2/+2
2013-07-16Rename Option swap_unwrap to take_unwrap. Fixes Issue#7764Austin King-3/+3
2013-07-14dlist: Use inline on very small functions and iterator functionsblake2-ppc-2/+25
2013-07-14dlist: Simplify by using Option::{map, map_mut}blake2-ppc-13/+4
These methods were fixed or just added so they can now be used.
2013-07-13dlist: Use a DoubleEndedIterator for .mut_iter() and .mut_rev_iter()blake2-ppc-79/+109
Unify the mutable iterators too. Switch the ListInsertion trait to use method .insert_next() and .peek_next() for list mutation. .insert_next() inserts an element into the list that will not appear in iteration, of course; so the length of the iteration can not change during iteration.
2013-07-13dlist: Use DoubleEndedIterator for .consume_rev_iter()blake2-ppc-12/+4
2013-07-13dlist: Implement DoubleEndedIterator and use for .iter() and .rev_iter()blake2-ppc-39/+33
2013-07-13dlist: Fix bug in DList::mergeblake2-ppc-11/+18
Did not properly allow runs from the `other` list to be merged in. The test case was using a wrong expected value. Edited docs for merge so they explain more clearly what it does. Also make sure insert_ordered is marked pub.
2013-07-11extra: Mention extra::container::Deque trait in doc for RingBuf and DListblake2-ppc-1/+4
2013-07-11dlist: Name the type DList for doubly-linked listblake2-ppc-67/+67
2013-07-11dlist: Fix license headerblake2-ppc-0/+9
2013-07-11dlist: Implement trait Dequeblake2-ppc-22/+25
2013-07-11dlist: Expose ListInsertion trait with insert_before and peek_nextblake2-ppc-12/+35
An iterator that allows mutating the list is very useful but needs care to not be unsound. ListIteration exposes only insert_before (used for insert_ordered) and peek_next so far.
2013-07-11dlist: Put all tests into a tests moduleblake2-ppc-258/+256
The exception is the function check_links which needs access to struct Node (which is not pub).
2013-07-11dlist: Collect a common pattern into link_with_prev()blake2-ppc-17/+15
2013-07-11dlist: Introduce a struct Rawlink mimicing Option<T> for a raw pointerblake2-ppc-62/+73
Rawlink<T> holds a *mut T pointer and can convert itself to Option<&mut T>. The null pointer is of course None.
2013-07-11dlist: Implement size_hint properly for all iteratorsblake2-ppc-8/+23
2013-07-11dlist: A new implementation of an owned doubly-linked listblake2-ppc-898/+834
This is an owned sendable linked list which allows insertion and deletion at both ends, with fast traversal through iteration, and fast append/prepend. It is indended to replace the previous managed DList with exposed list nodes. It does not match it feature by feature, but DList could grow more methods if needed.
2013-06-29Great renaming: propagate throughout the rest of the codebaseCorey Richardson-3/+1
2013-06-28extra: silence some test warnings.Huon Wilson-2/+0
2013-06-24remove old_iterDaniel Micay-58/+36
the `test/run-pass/class-trait-bounded-param.rs` test was xfailed and written in an ancient dialect of Rust so I've just removed it this also removes `to_vec` from DList because it's provided by `std::iter::to_vec` an Iterator implementation is added for OptVec but some transitional internal iterator methods are still left
2013-06-18replace #[inline(always)] with #[inline]. r=burningtree.Graydon Hoare-2/+2
2013-06-16Add copies to type params with Copy boundNiko Matsakis-8/+9
2013-06-14add IteratorUtil to the preludeDaniel Micay-1/+0