-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #174 from Emik03/search-alg-opt
Optimize search algorithms
- Loading branch information
Showing
16 changed files
with
828 additions
and
361 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,205 @@ | ||
AudioFile: '' | ||
SongPreviewTime: 0 | ||
BackgroundFile: '' | ||
MapId: -1 | ||
MapSetId: -1 | ||
Mode: Keys4 | ||
Title: '' | ||
Artist: '' | ||
Source: '' | ||
Tags: '' | ||
DifficultyName: '' | ||
EditorLayers: [] | ||
Bookmarks: | ||
- StartTime: 0 | ||
Note: 'first' | ||
- StartTime: 0 | ||
Note: 'first' | ||
- StartTime: 0 | ||
Note: 'first' | ||
- StartTime: 0 | ||
Note: 'first' | ||
- StartTime: 0 | ||
Note: 'first' | ||
- StartTime: 0 | ||
Note: 'first' | ||
- StartTime: 0 | ||
Note: 'first' | ||
- StartTime: 0 | ||
Note: 'first' | ||
- StartTime: 0 | ||
Note: 'first' | ||
- StartTime: 0 | ||
Note: 'first' | ||
- StartTime: 0 | ||
Note: 'first' | ||
- StartTime: 0 | ||
Note: 'first' | ||
- StartTime: 0 | ||
Note: 'second' | ||
- StartTime: 0 | ||
Note: 'third' | ||
- StartTime: 1000 | ||
Note: 'fourth' | ||
- StartTime: 1000 | ||
Note: 'fifth' | ||
- StartTime: 1000 | ||
Note: 'sixth' | ||
CustomAudioSamples: [] | ||
SoundEffects: [] | ||
TimingPoints: | ||
- StartTime: 0 | ||
Bpm: 6 | ||
Signature: 13646 | ||
- StartTime: 0 | ||
Bpm: 6 | ||
Signature: 13646 | ||
- StartTime: 0 | ||
Bpm: 6 | ||
Signature: 13646 | ||
- StartTime: 0 | ||
Bpm: 6 | ||
Signature: 13646 | ||
- StartTime: 0 | ||
Bpm: 6 | ||
Signature: 13646 | ||
- StartTime: 0 | ||
Bpm: 6 | ||
Signature: 13646 | ||
- StartTime: 0 | ||
Bpm: 6 | ||
Signature: 13646 | ||
- StartTime: 0 | ||
Bpm: 6 | ||
Signature: 13646 | ||
- StartTime: 0 | ||
Bpm: 6 | ||
Signature: 13646 | ||
- StartTime: 0 | ||
Bpm: 6 | ||
Signature: 13646 | ||
- StartTime: 0 | ||
Bpm: 6 | ||
Signature: 13646 | ||
- StartTime: 0 | ||
Bpm: 6 | ||
Signature: 13646 | ||
- StartTime: 0 | ||
Bpm: 4 | ||
Signature: 3 | ||
- StartTime: 0 | ||
Bpm: 12 | ||
Signature: 4 | ||
- StartTime: 1000 | ||
Bpm: 27 | ||
Signature: 246 | ||
- StartTime: 1000 | ||
Bpm: 1 | ||
Signature: 12 | ||
- StartTime: 1000 | ||
Bpm: 136 | ||
Signature: 3785 | ||
SliderVelocities: | ||
- StartTime: 0 | ||
Multiplier: 1253 | ||
- StartTime: 0 | ||
Multiplier: 1253 | ||
- StartTime: 0 | ||
Multiplier: 1253 | ||
- StartTime: 0 | ||
Multiplier: 1253 | ||
- StartTime: 0 | ||
Multiplier: 1253 | ||
- StartTime: 0 | ||
Multiplier: 1253 | ||
- StartTime: 0 | ||
Multiplier: 1253 | ||
- StartTime: 0 | ||
Multiplier: 1253 | ||
- StartTime: 0 | ||
Multiplier: 1253 | ||
- StartTime: 0 | ||
Multiplier: 1253 | ||
- StartTime: 0 | ||
Multiplier: 1253 | ||
- StartTime: 0 | ||
Multiplier: 1253 | ||
- StartTime: 0 | ||
Multiplier: 8.4 | ||
- StartTime: 0 | ||
Multiplier: -1345 | ||
- StartTime: 1000 | ||
Multiplier: 675 | ||
- StartTime: 1000 | ||
Multiplier: 0 | ||
- StartTime: 1000 | ||
Multiplier: -13548 | ||
HitObjects: | ||
- StartTime: 0 | ||
Lane: 4 | ||
KeySounds: [] | ||
HitSound: Normal | ||
- StartTime: 0 | ||
Lane: 4 | ||
KeySounds: [] | ||
HitSound: Normal | ||
- StartTime: 0 | ||
Lane: 4 | ||
KeySounds: [] | ||
HitSound: Normal | ||
- StartTime: 0 | ||
Lane: 4 | ||
KeySounds: [] | ||
HitSound: Normal | ||
- StartTime: 0 | ||
Lane: 4 | ||
KeySounds: [] | ||
HitSound: Normal | ||
- StartTime: 0 | ||
Lane: 4 | ||
KeySounds: [] | ||
HitSound: Normal | ||
- StartTime: 0 | ||
Lane: 4 | ||
KeySounds: [] | ||
HitSound: Normal | ||
- StartTime: 0 | ||
Lane: 4 | ||
KeySounds: [] | ||
HitSound: Normal | ||
- StartTime: 0 | ||
Lane: 4 | ||
KeySounds: [] | ||
HitSound: Normal | ||
- StartTime: 0 | ||
Lane: 4 | ||
KeySounds: [] | ||
HitSound: Normal | ||
- StartTime: 0 | ||
Lane: 4 | ||
KeySounds: [] | ||
HitSound: Normal | ||
- StartTime: 0 | ||
Lane: 4 | ||
KeySounds: [] | ||
HitSound: Normal | ||
- StartTime: 0 | ||
Lane: 3 | ||
KeySounds: [] | ||
HitSound: Normal | ||
- StartTime: 0 | ||
Lane: 2 | ||
KeySounds: [] | ||
HitSound: Normal | ||
- StartTime: 1000 | ||
Lane: 7 | ||
KeySounds: [] | ||
HitSound: Normal | ||
- StartTime: 1000 | ||
Lane: 1 | ||
KeySounds: [] | ||
HitSound: Normal | ||
- StartTime: 1000 | ||
Lane: 5 | ||
KeySounds: [] | ||
HitSound: Normal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
* Copyright (c) 2017-2018 Swan & The Quaver Team <[email protected]>. | ||
*/ | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Reflection; | ||
using System.Reflection.Emit; | ||
|
||
namespace Quaver.API.Helpers | ||
{ | ||
public static class ListHelper | ||
{ | ||
private static class Cache<T> | ||
{ | ||
public static Converter<List<T>, T[]> Converter { get; } = typeof(List<T>) | ||
.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) | ||
.FirstOrDefault(x => x.FieldType == typeof(T[])) is { } method | ||
? CreateGetter(method) | ||
: x => x.ToArray(); | ||
|
||
private static Converter<List<T>, T[]> CreateGetter(FieldInfo field) | ||
{ | ||
var name = $"{field.DeclaringType?.FullName}.get_{field.Name}"; | ||
var getter = new DynamicMethod(name, typeof(T[]), new[] { typeof(List<T>) }, true); | ||
var il = getter.GetILGenerator(); | ||
il.Emit(OpCodes.Ldarg_0); | ||
il.Emit(OpCodes.Ldfld, field); | ||
il.Emit(OpCodes.Ret); | ||
return (Converter<List<T>, T[]>)getter.CreateDelegate(typeof(Converter<List<T>, T[]>)); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Gets the underlying <see cref="Array"/> of the <see cref="List{T}"/>. | ||
/// </summary> | ||
/// <remarks><para> | ||
/// Be careful when using this method as the <see cref="List{T}"/> cannot safeguard | ||
/// against underlying mutations or out-of-bounds reading within its capacity. | ||
/// </para></remarks> | ||
/// <param name="list"></param> | ||
/// <typeparam name="T"></typeparam> | ||
/// <returns></returns> | ||
public static T[] GetUnderlyingArray<T>(List<T> list) => Cache<T>.Converter(list); | ||
} | ||
} |
Oops, something went wrong.