Example #1
0
 /*
  * Constructor.
  *
  * params:
  * f - filter to use in convolution
  * samples - source samples to filter
  * threadNum - thread index for this thread
  * chunkSize - number of samples to filter
  * cb - callback function to run after completion
  */
 public FilterThread(float[] f, int[] samples, int threadNum, int chunkSize, FilterCallback cb)
 {
     filter         = f;
     this.threadNum = threadNum;
     this.chunkSize = chunkSize;
     filterResult   = new float[(threadNum + 1) * chunkSize];
     fSamples       = samples;
     callback       = cb;
 }
Example #2
0
        /// <summary>
        /// Returns the elements of an array that meet the condition specified in a callback function.
        /// </summary>
        /// <param name="callbackfn">A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array.</param>
        /// <returns></returns>
        public JSArray <T> Filter(FilterCallback callbackfn)
        {
            JSArray <T> filteredArray = new JSArray <T>();

            for (int index = 0; index < this.Length; index++)
            {
                if (callbackfn(this[index], index, this))
                {
                    filteredArray.Push(this[index]);
                }
            }

            return(filteredArray);
        }
Example #3
0
        public static void Show(DirectoryInfo levelDir, FilterCallback filter, SelectionCallback callback)
        {
            //ListSelector ls = null;
            if (_instance == null)
            {
                _instance = ScriptableWizard.DisplayWizard <LevelPickerWizard>("Select level");
            }
            _instance._viewOnly = callback == null;
            _instance._levelDir = levelDir;
            _instance._filter   = filter;
            _instance._callback = callback;

            _instance.Refresh();

            _instance.Focus();
        }
    public static dfPrefabSelectionDialog Show( string title, Type componentType, SelectionCallback callback, PreviewCallback previewCallback, FilterCallback filterCallback = null )
    {
        var dialog = ScriptableWizard.DisplayWizard<dfPrefabSelectionDialog>( title );
        dialog.previewSize = DEFAULT_PREVIEW_SIZE;
        dialog.padding = DEFAULT_PADDING;
        dialog.componentType = componentType;
        dialog.minSize = new Vector2( 300, 200 );
        dialog.callback = callback;
        dialog.previewCallback = previewCallback;
        dialog.filterCallback = filterCallback;

        dialog.getFilteredItems();

        dialog.ShowAuxWindow();

        return dialog;
    }
        public IList <T> Filter(IList <T> outList, FilterCallback callback)
        {
            if (outList == null)
            {
                throw new ArgumentNullException("Out list is null");
            }

            if (callback == null)
            {
                throw new ArgumentNullException("callback");
            }

            foreach (T element in m_list)
            {
                if (callback(element))
                {
                    outList.Add(element);
                }
            }

            return(outList);
        }
Example #6
0
    public static dfPrefabSelectionDialog Show(string title, Type componentType, SelectionCallback callback, PreviewCallback previewCallback, FilterCallback filterCallback)
    {
        if (componentType == null)
        {
            throw new Exception("Component type cannot be null");
        }

        var dialog = ScriptableWizard.DisplayWizard <dfPrefabSelectionDialog>(title);

        dialog.previewSize     = DEFAULT_PREVIEW_SIZE;
        dialog.padding         = DEFAULT_PADDING;
        dialog.componentType   = componentType;
        dialog.minSize         = new Vector2(640, 480);
        dialog.callback        = callback;
        dialog.previewCallback = previewCallback;
        dialog.filterCallback  = filterCallback;

        dialog.getFilteredItems();

        dialog.ShowAuxWindow();

        return(dialog);
    }
Example #7
0
 public static Result ApplySessionChangeSet(this SQLite.SQLiteConnection db, SQLiteChangeSet changeSet, FilterCallback xFilter, ConflictCallback xConflict, object ctx)
 {
     return(ChangeSetApply(db, changeSet, xFilter, xConflict, ctx));
 }
Example #8
0
 private static extern Result ChangeSetApply(Sqlite3DatabaseHandle db, int changeSetBufferSize, Sqlite3ChangesetBuffer changeSetBuffer,
                                             [MarshalAs(UnmanagedType.FunctionPtr)] FilterCallback xFilter,
                                             [MarshalAs(UnmanagedType.FunctionPtr)] ConflictCallback xConflict,
                                             IntPtr pCtx);
Example #9
0
        /// <summary>
        /// Applies a given change set to provided db
        /// with possibility to limit which tables are changed via xFilter delegate,
        /// and custom conflict resolution via xConflict delegate
        /// See https://sqlite.org/session/sqlite3changeset_apply.html
        /// </summary>
        /// <param name="db">which db ("main" only) to apply changes to</param>
        /// <param name="changeSet">change set to apply to db</param>
        /// <param name="xFilter">use null to not filter, else delegate to limit tables changes applied to</param>
        /// <param name="xConflict">use null to ignore conflicts, else delegate to handle conflicts</param>
        /// <param name="ctx">context passed as first argument to xFilter and xConflict delegates</param>
        /// <returns></returns>
        public static Result ChangeSetApply(SQLite.SQLiteConnection db, SQLiteChangeSet changeSet, FilterCallback xFilter, ConflictCallback xConflict, object ctx)
        {
            Sqlite3DatabaseHandle dbHandle = db?.Handle ?? IntPtr.Zero;

            if (dbHandle == IntPtr.Zero)
            {
                return(Result.Misuse);
            }

            if (xConflict == null)
            {
                xConflict = new ConflictCallback(CallbackIgnoreConflicts);
            }

            // pinning not needed since just passing back thru; see https://blogs.msdn.microsoft.com/jmstall/2006/10/09/gchandle-tointptr-vs-gchandle-addrofpinnedobject/
            // Warning: if conflict handler is in unmanaged code then ctx should be pinned in Alloc and use AddrOfPinnedObject instead of ToIntPtr
            GCHandle gch    = GCHandle.Alloc(ctx);                                  // ok if ctx is null; pinning is unneeded since not kept past ChangeSetApply call
            IntPtr   pCtx   = (ctx == null) ? IntPtr.Zero : GCHandle.ToIntPtr(gch); // we don't pass GCHandle wrapper if null, instead pass NULL
            var      result = ChangeSetApply(dbHandle, changeSet.size, changeSet.buffer, xFilter, xConflict, pCtx);

            gch.Free();

            return(result);
        }
 public IList <T> Filter(FilterCallback callback)
 {
     return(Filter(new List <T>(), callback));
 }
Example #11
0
 public static IList <T> Filter <T>(this IList <T> collection, FilterCallback <T> callback) =>
 (
     from T item in collection
         where callback(item, collection.IndexOf(item), collection)
     select item
 ).ToList();