Example #1
0
File: 645.cs Project: pudae/lplpl
 private static IList<int> performTheExperiment(IList<int> xs)
 {
     var xs2 = xs.ToObservable().StartWith(0).Concat(Observable.Return(0))
     .Buffer(3, 1)
     .Where(l => l.Count == 3)
     .Select(l => changeSize(l[0], l[1], l[2]))
     .ToList()
     .First();
       if (xs.SequenceEqual(xs2))
     return xs;
       return performTheExperiment(xs2);
 }
Example #2
0
        public IEnumerable<ISonesIndex> GetIndices(IVertexType myVertexType, IList<IPropertyDefinition> myPropertyDefinition, SecurityToken mySecurityToken, Int64 myTransactionToken)
        {
            myVertexType.CheckNull("myVertexType");
            myPropertyDefinition.CheckNull("myPropertyDefinition");

            if (myPropertyDefinition.Count == 0)
                throw new ArgumentOutOfRangeException("myPropertyDefinition", "At least one property must be given.");

            var propertyTypes = myPropertyDefinition.GroupBy(_ => _.RelatedType);
            foreach (var group in propertyTypes)
            {
                if (!myVertexType.IsDescendantOrSelf(group.Key))
                {
                    throw new ArgumentException(string.Format("The properties ({0}) defined on type {1} is not part of inheritance hierarchy of {2}.",
                        string.Join(",", group.Select(_ => _.Name)),
                        group.Key.Name,
                        myVertexType.Name));
                }
            }

            var result = myVertexType.GetIndexDefinitions(false).Where(_ => myPropertyDefinition.SequenceEqual(_.IndexedProperties)).Select(_=>_indices[_.ID]).ToArray();

            return result;
        }
		public static IMember Resolve(ITypeResolveContext context,
		                              EntityType entityType,
		                              string name,
		                              ITypeReference explicitInterfaceTypeReference = null,
		                              IList<string> typeParameterNames = null,
		                              IList<ITypeReference> parameterTypeReferences = null)
		{
			if (context.CurrentTypeDefinition == null)
				return null;
			if (parameterTypeReferences == null)
				parameterTypeReferences = EmptyList<ITypeReference>.Instance;
			if (typeParameterNames == null || typeParameterNames.Count == 0) {
				// non-generic member
				// In this case, we can simply resolve the parameter types in the given context
				var parameterTypes = parameterTypeReferences.Resolve(context);
				if (explicitInterfaceTypeReference == null) {
					foreach (IMember member in context.CurrentTypeDefinition.Members) {
						if (member.IsExplicitInterfaceImplementation)
							continue;
						if (IsNonGenericMatch(member, entityType, name, parameterTypes))
							return member;
					}
				} else {
					IType explicitInterfaceType = explicitInterfaceTypeReference.Resolve(context);
					foreach (IMember member in context.CurrentTypeDefinition.Members) {
						if (!member.IsExplicitInterfaceImplementation)
							continue;
						if (member.ImplementedInterfaceMembers.Count != 1)
							continue;
						if (IsNonGenericMatch(member, entityType, name, parameterTypes)) {
							if (explicitInterfaceType.Equals(member.ImplementedInterfaceMembers[0].DeclaringType))
								return member;
						}
					}
				}
			} else {
				// generic member
				// In this case, we must specify the correct context for resolving the parameter types
				foreach (IMethod method in context.CurrentTypeDefinition.Methods) {
					if (method.EntityType != entityType)
						continue;
					if (method.Name != name)
						continue;
					if (method.Parameters.Count != parameterTypeReferences.Count)
						continue;
					// Compare type parameter count and names:
					if (!typeParameterNames.SequenceEqual(method.TypeParameters.Select(tp => tp.Name)))
						continue;
					// Once we know the type parameter names are fitting, we can resolve the
					// type references in the context of the method:
					var contextForMethod = context.WithCurrentMember(method);
					var parameterTypes = parameterTypeReferences.Resolve(contextForMethod);
					if (!IsParameterTypeMatch(method, parameterTypes))
						continue;
					if (explicitInterfaceTypeReference == null) {
						if (!method.IsExplicitInterfaceImplementation)
							return method;
					} else if (method.IsExplicitInterfaceImplementation && method.ImplementedInterfaceMembers.Count == 1) {
						IType explicitInterfaceType = explicitInterfaceTypeReference.Resolve(contextForMethod);
						if (explicitInterfaceType.Equals(method.ImplementedInterfaceMembers[0].DeclaringType))
							return method;
					}
				}
			}
			return null;
		}
        /// <summary>
        /// Comapres linked Objects details of recommendation action entity
        /// </summary>
        private static void CompareRecommendedActionLinkedObjects(IList<string> expected, IEnumerable<string> response)
        {
            Assert.False(expected != null ^ response != null);

            if (response != null)
            {
                Assert.True(expected.SequenceEqual(response));
            }
        }
Example #5
0
        public bool HaveSameSignature(
            IList<IParameterSymbol> parameters1,
            IList<IParameterSymbol> parameters2)
        {
            if (parameters1.Count != parameters2.Count)
            {
                return false;
            }

            return parameters1.SequenceEqual(parameters2, this.ParameterEquivalenceComparer);
        }
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Save the new list of writing systems to the database
		/// </summary>
		/// ------------------------------------------------------------------------------------
		protected void SaveWs(CheckedListBox lstBox, IList<IWritingSystem> currList, ICollection<IWritingSystem> allSet)
		{
			if (allSet.Count != lstBox.Items.Count || allSet.Intersect(lstBox.Items.Cast<IWritingSystem>()).Count() != allSet.Count)
			{
				var newWsIds = new List<string>();
				foreach (IWritingSystem ws in lstBox.Items)
				{
					string id = ws.IcuLocale;
					if (allSet.FirstOrDefault(existing => existing.IcuLocale == id) == null)
						newWsIds.Add(id);
				}
				allSet.Clear();
				foreach (IWritingSystem ws in lstBox.Items)
				{
					if (ws.Handle == 0)
						m_cache.ServiceLocator.WritingSystemManager.Replace(ws);
					allSet.Add(ws);
				}
				m_fWsChanged = true;
				foreach (var newWs in newWsIds)
				{
					// IcuLocale uses _ to separate, RFC5646 uses -.  We need the latter (see FWNX-1165).
					ProgressDialogWithTask.ImportTranslatedListsForWs(this, m_cache, newWs.Replace("_","-"));
				}
			}

			if (!currList.SequenceEqual(lstBox.CheckedItems.Cast<IWritingSystem>()))
			{
				currList.Clear();
				foreach (IWritingSystem ws in lstBox.CheckedItems)
					currList.Add(ws);
				m_fWsChanged = true;
			}
		}
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Save the new list of writing systems to the database
		/// </summary>
		/// ------------------------------------------------------------------------------------
		protected bool WsListChanged(CheckedListBox lstBox, IList<IWritingSystem> currList, ICollection<IWritingSystem> allSet)
		{
			if (allSet.Count != lstBox.Items.Count || allSet.Intersect(lstBox.Items.Cast<IWritingSystem>()).Count() != allSet.Count)
			{
				return true;
			}

			if (!currList.SequenceEqual(lstBox.CheckedItems.Cast<IWritingSystem>()))
			{
				return true;
			}
			return false;
		}
Example #8
0
        protected void assertNonLLStar( Grammar g, IList<int> expectedBadAlts )
        {
            DecisionProbe.verbose = true; // make sure we get all error info
            ErrorQueue equeue = new ErrorQueue();
            ErrorManager.SetErrorListener( equeue );

            // mimic actions of org.antlr.Tool first time for grammar g
            if ( g.NumberOfDecisions == 0 )
            {
                g.BuildNFA();
                g.CreateLookaheadDFAs( false );
            }
            NonRegularDecisionMessage msg = getNonRegularDecisionMessage( equeue.errors );
            Assert.IsNotNull(msg, "expected fatal non-LL(*) msg");
            List<int> alts = new List<int>();
            alts.AddRange( msg.altsWithRecursion );
            alts.Sort();
            //Collections.sort( alts );
            //Assert.AreEqual( expectedBadAlts, alts );
            Assert.IsTrue( expectedBadAlts.SequenceEqual( alts ) );
        }
 private void Write(IList<int> trueOutput, IList<int> output, ref int correct)
 {
     if (output.SequenceEqual(trueOutput))
     {
         correct++;
         Console.Write("+\t");
     }
     else
         Console.Write("-\t");
     foreach (var element in trueOutput)
     {
         Console.Write(element);
     }
     Console.Write("\t");
     foreach (var element in output)
     {
         Console.Write(element);
     }
     Console.WriteLine();
 }