Exemplo n.º 1
0
    protected override void copyData()
    {
        base.copyData();
        LongList playerIDListTemp = playerIDList;

        if (playerIDListTemp != null)
        {
            this.playerIDList = new LongList();
            LongList playerIDListT = this.playerIDList;
            if (!playerIDListTemp.isEmpty())
            {
                long[] playerIDListVValues = playerIDListTemp.getValues();
                for (int playerIDListVI = 0, playerIDListVLen = playerIDListTemp.length(); playerIDListVI < playerIDListVLen; ++playerIDListVI)
                {
                    long playerIDListV = playerIDListVValues[playerIDListVI];
                    long playerIDListU;
                    playerIDListU = playerIDListV;

                    playerIDListT.add(playerIDListU);
                }
            }
        }
        else
        {
            this.playerIDList = null;
            nullObjError("playerIDList");
        }
    }
Exemplo n.º 2
0
        public void LongListExpandTest()
        {
            var longList = new LongList <int> {
                ExpandListSize = 3
            };

            for (int i = 0; i < 6; ++i)
            {
                longList.Add(i);
            }
            Assert.Equal(longList.Count, 6);
            Assert.NotNull(longList.GetItem(4));

            bool didEnum = false;

            foreach (var j in longList)
            {
                didEnum = true;
                break;
            }

            Assert.True(didEnum);

            longList.RemoveAt(4);
            Assert.Equal(longList.Count, 5);
        }
Exemplo n.º 3
0
        public override LongList CheckDividendsOfPreviousTerm(Empty input)
        {
            var termNumber = State.ConsensusContract.GetCurrentTermNumber.Call(new Empty()).Value - 1;
            var result     = new LongList();

            if (termNumber < 1)
            {
                return(new LongList {
                    Values = { 0 }
                });
            }

            const long ticketsAmount = 10_000;
            var        lockTimes     = new List <int> {
                30, 180, 365, 730, 1095
            };

            foreach (var lockTime in lockTimes)
            {
                result.Values.Add(CheckDividends(new CheckDividendsInput
                {
                    TermNumber    = termNumber,
                    TicketsAmount = ticketsAmount,
                    LockTime      = lockTime
                }).Value);
            }

            return(result);
        }
        protected override void OnNavigatedFrom(System.Windows.Navigation.NavigationEventArgs e)
        {
            if (e.Content is IExerciseListInvoker)
            {
                (e.Content as IExerciseListInvoker).SelectedExercise = SelectedExercise;
            }
            base.OnNavigatedFrom(e);
            var list = LongList.GetItemsWithContainers(true, false);

            if (list.Count > 0)
            {//GroupingLayer<string, ExerciseViewModel>
                object first    = list.First();
                var    group    = first as GroupingLayer <string, ExerciseViewModel>;
                var    exercise = first as ExerciseViewModel;
                if (group != null)
                {
                    //State["SelectedGroup"] = group.Key;
                    State["SelectedExercise"] = ((ExerciseViewModel)list.ElementAt(1)).Exercise.GlobalId;
                }
                else if (exercise != null)
                {
                    State["SelectedExercise"] = exercise.Exercise.GlobalId;
                }
                //State["SelectedExercise"] = ((ExerciseViewModel) list.First()).Exercise.GlobalId;
            }
            //LongList
        }
 private void restoreListPosition()
 {
     try
     {
         StateHelper stateHelper = new StateHelper(this.State);
         var         item        = stateHelper.GetValue <Guid>("SelectedExercise", Guid.Empty);
         var         gr          = stateHelper.GetValue <string>("SelectedGroup", null);
         if (item != Guid.Empty)
         {
             LongList.UpdateLayout();
             var exerciseToScroll = ViewModel.GetExerciseView(item);
             LongList.ScrollTo(exerciseToScroll);
         }
         else if (gr != null)
         {
             //LongList.UpdateLayout();
             var t  = from g in (ObservableCollection <GroupingLayer <string, ExerciseViewModel> >)LongList.ItemsSource where g.Key == gr select g;
             var tt = t.Single();
             LongList.ScrollToGroup(tt);
         }
     }
     catch
     {
         LongList.ItemsSource = null;
         LongList.ItemsSource = ViewModel.GroupedExercises;
     }
 }
Exemplo n.º 6
0
            /// <summary>
            /// Creates a new object that is a copy of the current instance.
            /// </summary>
            public LongList Clone()
            {
                LongList copy = new LongList();

                copy._bits = (byte[])_bits.Clone();
                return(copy);
            }
Exemplo n.º 7
0
            /// <summary> Returns the 1's compliment (inverts) of the list up to Ceiling </summary>
            public LongList Invert(long ceiling)
            {
                unchecked
                {
                    byte[] copy = new byte[_bits.Length];
                    for (int i = 0; i < _bits.Length; i++)
                    {
                        copy[i] = (byte)~_bits[i];
                    }

                    LongList result = new LongList();
                    result._bits = copy;

                    result.Ceiling = ceiling;
                    long limit = result.Ceiling;
                    for (long i = Ceiling; i < limit; i++)
                    {
                        result.Add(i);
                    }
                    for (long i = ceiling + 1; i <= limit; i++)
                    {
                        result.Remove(i);
                    }

                    return(result);
                }
            }
Exemplo n.º 8
0
/*AUTO SCRIPT*/
/*AUTO SCRIPT*/ public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
/*AUTO SCRIPT*/ {
/*AUTO SCRIPT*/ if (list == null)
/*AUTO SCRIPT*/ {
/*AUTO SCRIPT*/ list  = EditorUtility.GetPropertyObject <LongList>(property);
/*AUTO SCRIPT*/ rList = new ReorderableList(list, typeof(long), true, false, true, true);
/*AUTO SCRIPT*/                         // rList.onAddCallback += data => { list.Add(defaultVal); };
/*AUTO SCRIPT*/                         // rList.onChangedCallback += data=> {
/*AUTO SCRIPT*/                         // };
/*AUTO SCRIPT*/ }
/*AUTO SCRIPT*/
/*AUTO SCRIPT*/ numLines = 3 + list.Count;
/*AUTO SCRIPT*/ var title  = new GUIContent($" {label.text}");
/*AUTO SCRIPT*/ var height = base.GetPropertyHeight(property, label);
/*AUTO SCRIPT*/ var rect   = new Rect(position.x, position.y, position.width, height);

/*AUTO SCRIPT*/ EditorGUI.BeginChangeCheck();
/*AUTO SCRIPT*/ rList.DoList(rect);
/*AUTO SCRIPT*/ EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), title);
/*AUTO SCRIPT*/
/*AUTO SCRIPT*/ if (EditorGUI.EndChangeCheck())
            {
/*AUTO SCRIPT*/ property.serializedObject.ApplyModifiedProperties();
            }
/*AUTO SCRIPT*/
/*AUTO SCRIPT*/ }
Exemplo n.º 9
0
    /// <summary>
    /// 创建实例
    /// </summary>
    public static AddAllFriendRequest create(LongList playerIDList, int type)
    {
        AddAllFriendRequest re = (AddAllFriendRequest)BytesControl.createRequest(dataID);

        re.playerIDList = playerIDList;
        re.type         = type;
        return(re);
    }
Exemplo n.º 10
0
 private void LockResourcesOnMaster(LockTracer tracer, ResourceType type, LongList ids)
 {
     long[] resourceIds = ids.toArray();
     using (LockWaitEvent @event = tracer.WaitForLock(false, type, resourceIds))
     {
         AcquireSharedOnMaster(type, resourceIds);
     }
 }
Exemplo n.º 11
0
 void LongList_GroupViewOpened(object sender, GroupViewOpenedEventArgs e)
 {
     if (buttonPressed)
     {
         LongList.CloseGroupView();
     }
     buttonPressed = false;
 }
Exemplo n.º 12
0
        [InlineData(100L)]  // Index larger than elements
        public void RemoveOutOfRange(long index)
        {
            // If: I construct a new long list
            LongList <char> ll = new LongList <char>();

            // Then:
            // ... There should be no values in the list
            Assert.Throws <ArgumentOutOfRangeException>(() => ll.RemoveAt(index));
        }
Exemplo n.º 13
0
        public void LongListConstruction()
        {
            // If: I construct a new long list
            LongList <char> ll = new LongList <char>();

            // Then:
            // ... There should be no values in the list
            Assert.Equal(0, ll.Count);
        }
Exemplo n.º 14
0
        public void LongListTest()
        {
            var longList = new LongList <char>();

            longList.Add('.');
            Assert.True(longList.Count == 1);
            longList.RemoveAt(0);
            Assert.True(longList.Count == 0);
        }
Exemplo n.º 15
0
        [InlineData(100L)]  // Index larger than elements
        public void SetItemOutOfRange(long index)
        {
            // If: I construct a new long list
            LongList <int> ll = new LongList <int>();

            // Then:
            // ... There should be no values in the list
            Assert.Throws <ArgumentOutOfRangeException>(() => ll[index] = 8);
            Assert.Throws <ArgumentOutOfRangeException>(() => ll.SetItem(index, 8));
        }
Exemplo n.º 16
0
        [InlineData(2)]    // Element at end
        public void GetItemNotExpanded(long index)
        {
            // If: I construct a new long list with a couple items in it
            LongList <int> ll = new LongList <int> {
                0, 1, 2
            };

            // Then: I can read back the value from the list
            Assert.Equal(3, ll.Count);
            Assert.Equal(index, ll[index]);
            Assert.Equal(index, ll.GetItem(index));
        }
Exemplo n.º 17
0
        private bool IsCorrupt(long offset)
        {
            LongList list = corruptObjects;

            if (list == null)
            {
                return(false);
            }
            lock (list)
            {
                return(list.Contains(offset));
            }
        }
Exemplo n.º 18
0
        public static long[][] ConvertState(LongList[] state)
        {
            long[][] labelIdsByNodeIndex = new long[state.Length][];
            for (int i = 0; i < state.Length; i++)
            {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.eclipse.collections.api.list.primitive.LongList labelIdList = state[i];
                LongList labelIdList = state[i];
                if (labelIdList != null)
                {
                    labelIdsByNodeIndex[i] = labelIdList.toArray();
                }
            }
            return(labelIdsByNodeIndex);
        }
Exemplo n.º 19
0
 public PluginData(
     string name,
     string group,
     string description,
     IClientData clientData,
     PluginFlags flags,
     Version version,
     Uri uri,
     AppDomain appDomain,
     Assembly assembly,
     AssemblyName assemblyName,
     string fileName,
     string typeName,
     CommandDataList commands,
     PolicyDataList policies,
     LongList commandTokens,
     LongList functionTokens,
     LongList policyTokens,
     LongList traceTokens,
     ResourceManager resourceManager,
     ObjectDictionary auxiliaryData,
     long token
     )
 {
     this.kind            = IdentifierKind.PluginData;
     this.id              = AttributeOps.GetObjectId(this);
     this.name            = name;
     this.group           = group;
     this.description     = description;
     this.clientData      = clientData;
     this.flags           = flags;
     this.version         = version;
     this.uri             = uri;
     this.appDomain       = appDomain;
     this.assembly        = assembly;
     this.assemblyName    = assemblyName;
     this.fileName        = fileName;
     this.typeName        = typeName;
     this.commands        = commands;
     this.policies        = policies;
     this.commandTokens   = commandTokens;
     this.functionTokens  = functionTokens;
     this.policyTokens    = policyTokens;
     this.traceTokens     = traceTokens;
     this.resourceManager = resourceManager;
     this.auxiliaryData   = auxiliaryData;
     this.token           = token;
 }
Exemplo n.º 20
0
        public void RemoveAtExpanded()
        {
            // If:
            // ... I create a long list that is guaranteed to be expanded
            //     (Created with 2x the values, evaluate the )
            LongList <int> ll = new LongList <int> {
                ExpandListSize = 2
            };

            for (int j = 0; j < 2; j++)
            {
                for (int i = 0; i < 10; i++)
                {
                    ll.Add(i);
                }
            }

            // ... And I delete all of the first half of values
            //     (we're doing this backwards to make sure remove works at different points in the list)
            for (int i = 9; i >= 0; i--)
            {
                ll.RemoveAt(i);
            }

            // Then:
            // ... The second half of the values should still remain
            for (int i = 0; i < 10; i++)
            {
                Assert.Equal(i, ll[i]);
            }

            // If:
            // ... I then proceed to add elements onto the end again
            for (int i = 0; i < 10; i++)
            {
                ll.Add(i);
            }

            // Then: All the elements should be there, in order
            for (int j = 0; j < 2; j++)
            {
                for (int i = 0; i < 10; i++)
                {
                    int index = j * 10 + i;
                    Assert.Equal(i, ll[index]);
                }
            }
        }
Exemplo n.º 21
0
        ///////////////////////////////////////////////////////////////////////////////////////////////

        public static string Format( /* 0.1 */
            IDictionary <long, string> flags,
            bool legacy,
            bool compact,
            bool space,
            bool sort,
            ref Result error
            )
        {
            if (flags != null)
            {
                StringBuilder result = StringOps.NewStringBuilder();
                LongList      keys   = new LongList(flags.Keys);

                if (sort)
                {
                    keys.Sort(); /* NOTE: O(N^2) is the worst case. */
                }
                for (int index = 0; index < keys.Count; index++)
                {
                    long key = keys[index];

                    string keyFlags = compact ? (string)DictionaryToChars(
                        CharsToDictionary(flags[key]), sort) : flags[key];

                    if (key != NoKey)
                    {
                        result.AppendFormat(
                            legacy ? LegacyFlagFormat : FlagFormat,
                            key, keyFlags);
                    }
                    else
                    {
                        result.Append(keyFlags);
                    }

                    if (space && ((index + 1) < keys.Count))
                    {
                        result.Append(Characters.Space);
                    }
                }

                return(result.ToString());
            }

            error = "invalid flags";
            return(null);
        }
Exemplo n.º 22
0
        /// <summary>
        /// Creates a new result set and initializes its state
        /// </summary>
        /// <param name="ordinal">The ID of the resultset, the ordinal of the result within the batch</param>
        /// <param name="batchOrdinal">The ID of the batch, the ordinal of the batch within the query</param>
        /// <param name="factory">Factory for creating a reader/writer</param>
        public ResultSet(int ordinal, int batchOrdinal, IFileStreamFactory factory)
        {
            Id      = ordinal;
            BatchId = batchOrdinal;

            // Initialize the storage
            totalBytesWritten = 0;
            outputFileName    = factory.CreateFile();
            fileOffsets       = new LongList <long>();
            specialAction     = new SpecialAction();

            // Store the factory
            fileStreamFactory = factory;
            hasBeenRead       = false;
            SaveTasks         = new ConcurrentDictionary <string, Task>();
        }
Exemplo n.º 23
0
        /// <summary>
        /// Creates a new result set and initializes its state
        /// </summary>
        /// <param name="reader">The reader from executing a query</param>
        /// <param name="factory">Factory for creating a reader/writer</param>
        public ResultSet(DbDataReader reader, IFileStreamFactory factory)
        {
            // Sanity check to make sure we got a reader
            Validate.IsNotNull(nameof(reader), SR.QueryServiceResultSetReaderNull);

            DataReader = new StorageDataReader(reader);

            // Initialize the storage
            outputFileName = factory.CreateFile();
            FileOffsets    = new LongList <long>();

            // Store the factory
            fileStreamFactory = factory;
            hasBeenRead       = false;
            saveTasks         = new ConcurrentDictionary <string, Task>();
        }
Exemplo n.º 24
0
            /// <summary> Returns the set of items that are in either this set or the provided set </summary>
            /// <example>{ 1, 2, 3 }.UnionWith({ 2, 3, 4 }) == { 1, 2, 3, 4 }</example>
            public LongList UnionWith(LongList other)
            {
                byte[] small, big;
                big   = _bits.Length > other._bits.Length ? _bits : other._bits;
                small = _bits.Length > other._bits.Length ? other._bits : _bits;

                byte[] newbits = (byte[])big.Clone();
                for (int i = 0; i < small.Length; i++)
                {
                    newbits[i] |= small[i];
                }

                LongList result = new LongList();

                result._bits = newbits;
                return(result);
            }
Exemplo n.º 25
0
        public void SetItemIndexerNotExpanded()
        {
            // If:
            // ... I construct a new long list with a few items in it
            // ... And I set all values to new values
            LongList <int> ll = new LongList <int> {
                0, 1, 2
            };

            for (int i = 0; i < ll.Count; i++)
            {
                ll[i] = 8;
            }

            // Then: All values in the list should be 8
            Assert.All(ll, i => Assert.Equal(8, i));
        }
Exemplo n.º 26
0
        [InlineData(100)]   // Far too large
        public void LongSkipOutOfRange(long index)
        {
            // Setup: Create a long list with a handful of elements
            LongList <int> ll = new LongList <int> {
                ExpandListSize = 2
            };

            for (int i = 0; i < 5; i++)
            {
                ll.Add(i);
            }

            // If: I attempt to skip ahead by a value that is out of range
            // Then: I should get an exception
            // NOTE: We must do the .ToList in order to evaluate the LongSkip since it is implemented
            //       with a yield return
            Assert.Throws <ArgumentOutOfRangeException>(() => ll.LongSkip(index).ToArray());
        }
Exemplo n.º 27
0
        public void GetEnumerator()
        {
            // Setup: Create a long list with a handful of elements
            LongList <int> ll = new LongList <int>();

            for (int i = 0; i < 5; i++)
            {
                ll.Add(i);
            }

            // If: I get iterate over the list via GetEnumerator
            // Then: All the elements should be returned, in order
            int val = 0;

            foreach (int element in ll)
            {
                Assert.Equal(val++, element);
            }
        }
Exemplo n.º 28
0
        [InlineData(2)]    // Skip within the short list
        public void LongSkip(long index)
        {
            // Setup: Create a long list with a handful of elements
            LongList <int> ll = new LongList <int>();

            for (int i = 0; i < 5; i++)
            {
                ll.Add(i);
            }

            // If: I skip ahead by a few elements and get all elements in an array
            int[] values = ll.LongSkip(index).ToArray();

            // Then: The elements including the skip start index should be in the output
            for (int i = 0; i < values.Length; i++)
            {
                Assert.Equal(ll[i + index], values[i]);
            }
        }
Exemplo n.º 29
0
    /// <summary>
    /// 转文本输出
    /// </summary>
    protected override void toWriteDataString(DataWriter writer)
    {
        base.toWriteDataString(writer);

        writer.writeTabs();
        writer.sb.Append("playerIDList");
        writer.sb.Append(':');
        writer.sb.Append("List<long>");
        if (this.playerIDList != null)
        {
            LongList playerIDListT   = this.playerIDList;
            int      playerIDListLen = playerIDListT.size();
            writer.sb.Append('(');
            writer.sb.Append(playerIDListLen);
            writer.sb.Append(')');
            writer.writeEnter();
            writer.writeLeftBrace();
            for (int playerIDListI = 0; playerIDListI < playerIDListLen; ++playerIDListI)
            {
                long playerIDListV = playerIDListT.get(playerIDListI);
                writer.writeTabs();
                writer.sb.Append(playerIDListI);
                writer.sb.Append(':');
                writer.sb.Append(playerIDListV);

                writer.writeEnter();
            }
            writer.writeRightBrace();
        }
        else
        {
            writer.sb.Append("=null");
        }

        writer.writeEnter();
        writer.writeTabs();
        writer.sb.Append("type");
        writer.sb.Append(':');
        writer.sb.Append(this.type);

        writer.writeEnter();
    }
Exemplo n.º 30
0
        private void SetCorrupt(long offset)
        {
            LongList list = corruptObjects;

            if (list == null)
            {
                lock (readLock)
                {
                    list = corruptObjects;
                    if (list == null)
                    {
                        list           = new LongList();
                        corruptObjects = list;
                    }
                }
            }
            lock (list)
            {
                list.Add(offset);
            }
        }