Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ environment:
# DVersion: 2.080.0
# arch: x86
- DC: ldc
DVersion: '1.16.0-beta2'
DVersion: '1.18.0'
arch: x64

matrix:
Expand Down
13 changes: 12 additions & 1 deletion doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,18 @@ ARTWORK_DIR=$(DOC_SOURCE_DIR)/artwork
# packages and their modules.
MIR_PACKAGES = mir mir/rc mir/ndslice mir/ndslice/connect mir/math mir/math/func mir/array mir/interpolate mir/graph mir/combinatorics mir/container mir/algorithm

PACKAGE_mir = range series numeric type_info small_string small_array polynomial
PACKAGE_mir = \
range \
series \
numeric \
type_info \
small_string \
small_array \
polynomial \
format\
parse\
appender\
exception\

PACKAGE_mir_algorithm = iteration setops
PACKAGE_mir_array = allocation
Expand Down
4 changes: 3 additions & 1 deletion dub.sdl
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ buildType "unittest-release" {
versions "mir_test"
}

dflags "-preview=dip1008"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was this deliberate? It breaks anyone who can't use dip1008.

Also, dub doesn't propagate dflags to the whole build, only to packages that depend on the package that sets them, which means you end up building part of the build with dip1008 and part without. I noticed because linker errors where something was @nogc in the root package but not in its dependencies. So in general it just doesn't work to set dip flags in a library config.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. Interesting is there a case when the DIP can't be used? I thought it is quite good.

I will create a patch tomorrow.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, there probably aren't many practical cases where you can't use it (maybe if you catch and store exceptions?), but nonetheless it does cause quite confusing breakage (because dub and dflags don't work well)

configuration "default" {
}

configuration "dips" {
dflags "-preview=dip1000" "-preview=dip1008"
dflags "-preview=dip1000"
}
4 changes: 4 additions & 0 deletions index.d
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ $(BOOKTABLE ,
$(LEADINGROW Containers)
$(TR $(TDNW $(MREF mir,series)★) $(TD Generic series suitable for time-series or semi-immutable ordered maps with CPU cache friendly binary search.))
$(TR $(TDNW $(MREF mir,container,binaryheap)★) $(TD Mir & BetterC rework of Phobos.))
$(TR $(TDNW $(MREF mir,appender)) $(TD Scoped Buffer.))
$(LEADINGROW Graphs)
$(TR $(TDNW $(MREF mir,graph)) $(TD Basic routines to work with graphs))
$(TR $(TDNW $(MREF mir,graph,tarjan)★) $(TD Tarjan's strongly connected components algorithm))
Expand All @@ -38,6 +39,9 @@ $(BOOKTABLE ,
$(LEADINGROW Interconnection with other languages)
$(TR $(TDNW $(MREF mir,ndslice,connect,cpython)) $(TD Utilities for $(HTTPS docs.python.org/3/c-api/buffer.html, Python Buffer Protocol)))
$(LEADINGROW Accessories)
$(TR $(TDNW $(MREF mir,exception)) $(TD @nogc MirException with formatting))
$(TR $(TDNW $(MREF mir,format)) $(TD @nogc Formatting Utilities))
$(TR $(TDNW $(MREF mir,parse)) $(TD @nogc Parsing Utilities))
$(TR $(TDNW $(MREF mir,small_array)) $(TD Generic Small Arrays))
$(TR $(TDNW $(MREF mir,small_string)) $(TD Generic Small Strings))
$(TR $(TDNW $(MREF mir,array,allocation)) $(TD `std.array` reworked for Mir))
Expand Down
5 changes: 5 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@ required_deps = [mir_core_dep]
mir_algorithm_src = [
'source/mir/algorithm/iteration.d',
'source/mir/algorithm/setops.d',
'source/mir/appender.d',
'source/mir/array/allocation.d',
'source/mir/combinatorics/package.d',
'source/mir/container/binaryheap.d',
'source/mir/cpp_export/numeric.d',
'source/mir/exception.d',
'source/mir/format_impl.d',
'source/mir/format.d',
'source/mir/graph/package.d',
'source/mir/graph/tarjan.d',
'source/mir/interpolate/constant.d',
Expand Down Expand Up @@ -52,6 +56,7 @@ mir_algorithm_src = [
'source/mir/ndslice/topology.d',
'source/mir/ndslice/traits.d',
'source/mir/numeric.d',
'source/mir/parse.d',
'source/mir/polynomial.d',
'source/mir/range.d',
'source/mir/rc/array.d',
Expand Down
39 changes: 32 additions & 7 deletions source/mir/algorithm/setops.d
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ Authors: $(HTTP erdani.com, Andrei Alexandrescu) (original Phobos code), Ilya Ya
*/
module mir.algorithm.setops;

import core.lifetime: move;
import mir.functional: naryFun;
import mir.primitives;
import mir.qualifier;
import std.range.primitives: isRandomAccessRange;

/**
Merges multiple sets. The input sets are passed as a
Expand Down Expand Up @@ -43,6 +47,7 @@ want to pass a duplicate to $(D MultiwayMerge) (and perhaps cache the
duplicate in between calls).
*/
struct MultiwayMerge(alias less, RangeOfRanges)
if (isRandomAccessRange!RangeOfRanges)
{
import mir.primitives;
import mir.container.binaryheap;
Expand All @@ -66,12 +71,22 @@ struct MultiwayMerge(alias less, RangeOfRanges)
///
this(RangeOfRanges ror)
{
import std.algorithm.mutation : remove, SwapStrategy;

// Preemptively get rid of all empty ranges in the input
// No need for stability either
auto temp = ror.lightScope;
for (;!temp.empty;)
{
if (!temp.empty)
{
temp.popFront;
continue;
}
move(temp.back, temp.front);
temp.popBack;
ror.popBack;
}
//Build the heap across the range
_heap = typeof(_heap)(ror.remove!("a.empty", SwapStrategy.unstable));
_heap = typeof(_heap)(ror.move);
}

///
Expand Down Expand Up @@ -100,7 +115,7 @@ MultiwayMerge!(naryFun!less, RangeOfRanges) multiwayMerge
(alias less = "a < b", RangeOfRanges)
(RangeOfRanges ror)
{
return typeof(return)(ror);
return typeof(return)(move(ror));
}

///
Expand Down Expand Up @@ -152,11 +167,11 @@ auto multiwayUnion(alias less = "a < b", RangeOfRanges)(RangeOfRanges ror)
import mir.functional: not;
import mir.algorithm.iteration : Uniq;

return Uniq!(not!less, typeof(multiwayMerge!less(ror)))(multiwayMerge!less(ror));
return Uniq!(not!less, typeof(multiwayMerge!less(ror)))(multiwayMerge!less(move(ror)));
}

///
@system version(mir_test) unittest
@safe version(mir_test) unittest
{
import std.algorithm.comparison : equal;

Expand Down Expand Up @@ -199,10 +214,20 @@ pragma(inline, false)
size_t unionLength(alias less = "a < b", RangeOfRanges)(RangeOfRanges ror)
{
size_t length;
auto u = ror.multiwayUnion!less;
auto u = move(ror).multiwayUnion!less;
if (!u.empty) do {
length++;
u.popFront;
} while(!u.empty);
return length;
}

/++
+/
auto rcunion(alias less = "a < b", RangeOfRanges)(RangeOfRanges ror)
{
import mir.rc.array;
auto length = unionLength!less(ror.lightScope);
auto u = multiwayUnion!less(ror.move);

}
Loading