Commit Graph

177 Commits

Author SHA1 Message Date
Ilya Gorbunov f604eef2fe Undeprecate find(predicate) and generate it for all collection-like types. Provide findLast(predicate).
Drop deprecated method findNot and extension properties first, last, head, tail
#KT-5185 Fixed
2015-07-24 04:28:46 +03:00
Ilya Gorbunov 1cc94f92e2 Also generate contains for meaningless combinations of types to prevent mistakenly using contains from an Iterable.
#KT-6361
2015-07-24 04:28:34 +03:00
Ilya Gorbunov b7fbb60db4 Generate contains function for all combinations of primitive numeric ranges and arguments.
#KT-6361
2015-07-24 04:14:06 +03:00
Ilya Gorbunov 71f3e3049a Provide until function to construct integer ranges with an end being excluded from range.
#KT-4665 Fixed
2015-07-24 04:13:41 +03:00
Ilya Gorbunov 808170a84b Generate range downTos with templates DSL 2015-07-24 04:13:29 +03:00
Ilya Gorbunov 2c396cf28e Add clarification about the lazy nature of Sequence.plus and Sequence.minus operations. 2015-07-17 10:54:54 +03:00
Ilya Gorbunov 8ac613dd67 Fix docs for String.partition
#KT-8493 Fixed
2015-07-17 10:54:40 +03:00
Ilya Gorbunov fbd0c16551 Merging arrays without creating iterators. 2015-07-17 10:54:28 +03:00
Ilya Gorbunov 9d120dcd44 Provide minus and minusAssign for iterables, collections, sets, sequences.
removeAll and retainAll special case optimizations.
#KT-3721 Fixed
#KT-7466 Fixed
2015-07-17 10:53:18 +03:00
Ilya Gorbunov 048a3ebcc1 Implement plus for sequence as operand and refactor plus tests. 2015-07-17 10:53:05 +03:00
Ilya Gorbunov a7bf415ad5 plus: do not generate ambiguos overloads. 2015-07-17 10:51:35 +03:00
Ilya Gorbunov d89af24d6c Variance of arrays sorted out.
Use concat for array + 1 in JS.
2015-07-17 10:51:22 +03:00
Ilya Gorbunov 7866184eb6 Array.plus — different implementations for JVM and JS.
Array.copyOf, copyOfRange available in JS.
2015-07-17 10:51:09 +03:00
Ilya Gorbunov c883df544c Make plus operation to be strict binary or right external binary for Sets and Arrays. 2015-07-17 10:50:58 +03:00
Ilya Gorbunov 0a320a13e5 Stdlib generators: change constants for Long: ZERO, ONE, -ONE. 2015-07-15 17:21:52 +03:00
Ilya Gorbunov 96b79eebe7 asSequence returns empty sequence singleton for empty arrays and strings.
#KT-8450 Fixed
2015-07-15 17:08:27 +03:00
Denis Zharkov 4479c215d4 Change return type for iterator method of asList impls for *Array
These objects implement AbstractList that extending MutableCollection.
After type propagation `iterator` of AbstractList become MutableIterator, so it cannot be overriden with immutable Iterator
2015-07-09 16:36:46 +03:00
Ilya Gorbunov f7436064d0 Unify componentN templates and add NOTHING_TO_INLINE suppression. 2015-07-03 16:38:10 +03:00
Ilya Gorbunov 9618a3542f Provide getOrElse and getOrNull methods for indexed collections.
Breaking: elementAtOrElse is no longer inlined for Iterables and Sequences.
#KT-6952
2015-07-03 16:38:08 +03:00
Ilya Gorbunov 4660b07687 StdLib cleanup: drop deprecated iterators and streams. 2015-06-29 17:06:45 +03:00
Ilya Gorbunov f3a19ebe11 StdLib deprecations cleanup: length, size, indices and other collection operations. 2015-06-29 17:06:20 +03:00
Ilya Gorbunov cbdaf2a151 Minor: regenerate generated code. 2015-06-26 19:40:56 +03:00
Ilya Gorbunov a80f65cfd9 Do not create empty list when reversing empty collection or array — use singleton empty list instead.
#KT-8099 Fixed
2015-06-19 19:41:10 +03:00
Ilya Gorbunov 4093147c69 Regenerate docs for intersect and subtract. (PR#703) 2015-06-18 15:13:48 +03:00
Ilya Gorbunov 009baa11fc Specific wording in exception message for String methods. 2015-06-04 16:45:55 +03:00
Ilya Gorbunov a1d8e9d633 Provide dropLast and takeLastWhile methods. Optimize special cases of drop/take/dropLast/takeLast (when n is equal to zero or size of collection). 2015-06-04 16:32:25 +03:00
Ilya Gorbunov 9b17220baa Provide dropLastWhile for Arrays, Lists and Strings. 2015-06-04 16:32:21 +03:00
Ilya Gorbunov 64b2e37436 Deprecate meaningless or vague-defined operations with Char operands: downTo. 2015-06-01 00:55:45 +03:00
Dmitry Jemerov 8f0f02fc59 correct some errors and omissions in stdlib doc comments 2015-05-28 14:38:36 +02:00
Ilya Gorbunov ea85290939 Annotate deprecated members with proposed replacement. 2015-05-27 22:29:37 +03:00
Ilya Gorbunov fa24db435d Stdlib documentation: clarified toMap behavior when a duplicate key is encountered. 2015-05-27 22:29:33 +03:00
Ilya Gorbunov ae60f7a32f Prettify kdocs and exception messages in the generated code. 2015-05-27 22:16:15 +03:00
Ilya Gorbunov 45c82f2844 map(): Take into account size of collection being transformed when allocating ArrayList.
#KT-7832 Fixed.
2015-05-26 23:23:36 +03:00
Ilya Gorbunov 01a0348685 Remove deprecated size property usage from generated code. 2015-05-26 23:23:32 +03:00
Ilya Gorbunov 6a3cb0eff8 Provide distinctBy(keySelector) method for collections and sequences.
Implement distinct() and toMutableSet() for sequences.
Breaking change: distinct() now returns List instead of Set.

#KT-5834 Fixed
#KT-6063 Fixed
2015-05-20 19:28:47 +03:00
Ilya Gorbunov 85e637b1e7 Revert toArrayList for primitive arrays back to trivial implementation.
Use newly introduced Int.MAX_VALUE in JS.
Inline mapCapacityForValues function.
Precalculate capacity of linked hash set being created with toMutableSet function.
2015-05-20 19:28:44 +03:00
Danny Thomas 7ce0487b7e Collection performance improvements
Lists

- For arrays, use Arrays.asList, then toArrayList making the list creation an array copy
- For the same reason, use the ArrayList(Collection) constructor
- Replace duplicate code in toList, instead calling toArrayList

Maps/Sets

- Where the size of the source is known, precalculate the capacity, using the formula used by Guava's Maps class
- For toMap where we're unable to get at the private function, use HashSet's formula where the size is known
- Add a toMap that takes a selector and a transform, avoiding a separate step for transforming values
2015-05-20 19:27:44 +03:00
Ilya Gorbunov 1fc5c39c22 Remove overload of joinToString with 5 parameters and it's usage from java code. 2015-05-15 03:02:48 +03:00
Ilya Gorbunov f7aa997003 Provide fast path for negative index values in elementAt.
Minor: kdoc wording.
2015-05-12 21:07:24 +03:00
Ilya Gorbunov a5ed5d4269 Generate elementAtOrNull and elementAtOrElse extension methods for iterables, collections, sequences, etc.
#KT-6952 Fixed
2015-05-12 20:08:20 +03:00
Ilya Gorbunov 16d20ff009 Temporary add jvm.overloads annotation for generated joinToString() method.
Stdlib generator: allow to specify arbitrary annotations for all or some of generic function expansions.
2015-05-09 01:11:49 +03:00
Ilya Gorbunov d531d7130f Add an optional parameter to joinToString() and joinTo() functions: lambda function which maps the element to string.
#KT-5468 Fixed
2015-05-09 01:11:47 +03:00
Ilya Gorbunov 7fba979372 Generate to[Primitive]Array() methods for generic arrays and collections.
#KT-4180 Fixed
2015-04-22 18:21:37 +03:00
Ilya Gorbunov 5dacb5a745 Provide average() method for iterables, sequences and arrays.
#KT-3843 Fixed
2015-04-22 18:21:29 +03:00
Ilya Gorbunov 9759be5493 Generate sum() methods for arrays, iterables and sequences of Byte and Short. These overloads got explicit platformName.
Heuristics to decide when to set platformName.
#KT-3714
2015-04-22 18:21:24 +03:00
Ilya Gorbunov ccc3646bb8 Generate coerceAtLeast, coerceAtMost and coerceIn extension functions for numbers and other Comparables. 2015-04-22 18:20:47 +03:00
Ilya Gorbunov 899a01e8c2 Rename sequence() extension to asSequence() 2015-04-22 17:57:20 +03:00
Ilya Gorbunov 9ed2cb3858 Provide zip() and merge() overloads for primitive arrays with themselves.
Better predicting size of resulting list of plus() operation.
#KT-4968 Fixed
2015-04-22 03:19:30 +03:00
Ilya Gorbunov 58310d172f Deprecate sequence implementations in favor of sequence operations. 2015-04-21 21:27:24 +03:00
Ilya Gorbunov 043b27bfe5 Make more generic signature for reduce and reduceRight methods.
Fixes #KT-2287
2015-04-15 17:34:08 +03:00