public override void Remove(Statement statement)
 {
     if (statement.AnyNull)
     {
         for (int i = 0; i < statements.Count; i++)
         {
             Statement s = (Statement)statements[i];
             if (statement.Matches(s))
             {
                 statements.RemoveAt(i); i--;
                 if (isIndexed)
                 {
                     GetIndexArray(statementsAboutSubject, s.Subject).Remove(s);
                     GetIndexArray(statementsAboutObject, s.Object).Remove(s);
                 }
             }
         }
     }
     else
     {
         statements.Remove(statement);
         if (isIndexed)
         {
             GetIndexArray(statementsAboutSubject, statement.Subject).Remove(statement);
             GetIndexArray(statementsAboutObject, statement.Object).Remove(statement);
         }
     }
 }
        public override void Select(Statement template, StatementSink result)
        {
            StatementList source = statements;

            // The first time select is called, turn indexing on for the store.
            // TODO: Perform this index in a background thread if there are a lot
            // of statements.
            if (!isIndexed && allowIndexing)
            {
                isIndexed = true;
                for (int i = 0; i < StatementCount; i++)
                {
                    Statement statement = this[i];
                    GetIndexArray(statementsAboutSubject, statement.Subject).Add(statement);
                    GetIndexArray(statementsAboutObject, statement.Object).Add(statement);
                }
            }

            if (template.Subject != null)
            {
                ShorterList(ref source, GetIndexArray(statementsAboutSubject, template.Subject));
            }
            else if (template.Object != null)
            {
                ShorterList(ref source, GetIndexArray(statementsAboutObject, template.Object));
            }

            if (source == null)
            {
                return;
            }

            for (int i = 0; i < source.Count; i++)
            {
                Statement statement = source[i];
                if (!template.Matches(statement))
                {
                    continue;
                }
                if (!result.Add(statement))
                {
                    return;
                }
            }
        }
		public override void Remove(Statement statement) {
			if (statement.AnyNull) {
				for (int i = 0; i < statements.Count; i++) {
					Statement s = (Statement)statements[i];
					if (statement.Matches(s)) {
						statements.RemoveAt(i); i--;
						if (isIndexed) {
							GetIndexArray(statementsAboutSubject, s.Subject).Remove(s);
							GetIndexArray(statementsAboutObject, s.Object).Remove(s);
						}
					}
				}
			} else {
				statements.Remove(statement);
				if (isIndexed) {
					GetIndexArray(statementsAboutSubject, statement.Subject).Remove(statement);
					GetIndexArray(statementsAboutObject, statement.Object).Remove(statement);
				}
			}
		}
		public override void Select(Statement template, StatementSink result) {
			StatementList source = statements;
			
			// The first time select is called, turn indexing on for the store.
			// TODO: Perform this index in a background thread if there are a lot
			// of statements.
			if (!isIndexed && allowIndexing) {
				isIndexed = true;
				for (int i = 0; i < StatementCount; i++) {
					Statement statement = this[i];
					GetIndexArray(statementsAboutSubject, statement.Subject).Add(statement);
					GetIndexArray(statementsAboutObject, statement.Object).Add(statement);
				}
			}
			
			if (template.Subject != null) ShorterList(ref source, GetIndexArray(statementsAboutSubject, template.Subject));
			else if (template.Object != null) ShorterList(ref source, GetIndexArray(statementsAboutObject, template.Object));
			
			if (source == null) return;
			
			for (int i = 0; i < source.Count; i++) {
				Statement statement = source[i];
				if (!template.Matches(statement))
					continue;
				if (!result.Add(statement)) return;
			}
		}