本文整理汇总了C#中System.Xml.Schema.BitSet.Or方法的典型用法代码示例。如果您正苦于以下问题:C# BitSet.Or方法的具体用法?C# BitSet.Or怎么用?C# BitSet.Or使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.Schema.BitSet
的用法示例。
在下文中一共展示了BitSet.Or方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConstructPos
public override void ConstructPos(BitSet firstpos, BitSet lastpos, BitSet[] followpos)
{
base.LeftChild.ConstructPos(firstpos, lastpos, followpos);
BitSet set = new BitSet(firstpos.Count);
BitSet set2 = new BitSet(lastpos.Count);
base.RightChild.ConstructPos(set, set2, followpos);
firstpos.Or(set);
lastpos.Or(set2);
}
示例2: ConstructChildPos
private static void ConstructChildPos(SyntaxTreeNode child, BitSet firstpos, BitSet lastpos, BitSet[] followpos) {
BitSet firstPosTemp = new BitSet(firstpos.Count);
BitSet lastPosTemp = new BitSet(lastpos.Count);
child.ConstructPos(firstPosTemp, lastPosTemp, followpos);
firstpos.Or(firstPosTemp);
lastpos.Or(lastPosTemp);
}
示例3: ConstructPos
public override void ConstructPos(BitSet firstpos, BitSet lastpos, BitSet[] followpos) {
BitSet firstPosTemp = new BitSet(firstpos.Count);
BitSet lastPosTemp = new BitSet(lastpos.Count);
SyntaxTreeNode n;
ChoiceNode this_ = this;
do {
ConstructChildPos(this_.RightChild, firstPosTemp, lastPosTemp, followpos);
n = this_.LeftChild;
this_ = n as ChoiceNode;
} while (this_ != null);
n.ConstructPos(firstpos, lastpos, followpos);
firstpos.Or(firstPosTemp);
lastpos.Or(lastPosTemp);
}
示例4: ExpectedElements
public override ArrayList ExpectedElements(ValidationState context, bool isRequiredOnly) {
ArrayList names = null;
BitSet expectedPos;
if (context.RunningPositions != null) {
List<RangePositionInfo> runningPositions = context.RunningPositions;
expectedPos = new BitSet(positions.Count);
for (int i = context.CurrentState.NumberOfRunningPos - 1; i >=0; i--) {
Debug.Assert(runningPositions[i].curpos != null);
expectedPos.Or(runningPositions[i].curpos);
}
for (int pos = expectedPos.NextSet(-1); pos != -1; pos = expectedPos.NextSet(pos)) {
if (names == null) {
names = new ArrayList();
}
int symbol = positions[pos].symbol;
if (symbol >= 0) { //non range nodes
XmlSchemaParticle p = positions[pos].particle as XmlSchemaParticle;
if (p == null) {
string s = symbols.NameOf(positions[pos].symbol);
if (s.Length != 0) {
names.Add(s);
}
}
else {
string s = p.NameString;
if (!names.Contains(s)) {
names.Add(s);
}
}
}
}
}
return names;
}
示例5: ExpectedParticles
public override ArrayList ExpectedParticles(ValidationState context, bool isRequiredOnly, XmlSchemaSet schemaSet) {
ArrayList particles = new ArrayList();
BitSet expectedPos;
if (context.RunningPositions != null) {
List<RangePositionInfo> runningPositions = context.RunningPositions;
expectedPos = new BitSet(positions.Count);
for (int i = context.CurrentState.NumberOfRunningPos - 1; i >=0; i--) {
Debug.Assert(runningPositions[i].curpos != null);
expectedPos.Or(runningPositions[i].curpos);
}
for (int pos = expectedPos.NextSet(-1); pos != -1; pos = expectedPos.NextSet(pos)) {
int symbol = positions[pos].symbol;
if (symbol >= 0) { //non range nodes
XmlSchemaParticle p = positions[pos].particle as XmlSchemaParticle;
if (p == null) {
continue;
}
AddParticleToExpected(p, schemaSet, particles);
}
}
}
return particles;
}
示例6: GetApplicableMinMaxFollowPos
//For each position, this method calculates the additional follows of any range nodes that need to be added to its followpos
//((ab?)2-4)c, Followpos of a is b as well as that of node R(2-4) = c
private BitSet GetApplicableMinMaxFollowPos(BitSet curpos, BitSet posWithRangeTerminals, BitSet[] minmaxFollowPos) {
if (curpos.Intersects(posWithRangeTerminals)) {
BitSet newSet = new BitSet(positions.Count); //Doing work again
newSet.Or(curpos);
newSet.And(posWithRangeTerminals);
curpos = curpos.Clone();
for (int pos = newSet.NextSet(-1); pos != -1; pos = newSet.NextSet(pos)) {
LeafRangeNode lrNode = positions[pos].particle as LeafRangeNode;
curpos.Or(minmaxFollowPos[lrNode.Pos]);
}
}
return curpos;
}
示例7: BuildTransitionTable
/// <summary>
/// Algorithm 3.5 Construction of a DFA from a regular expression
/// </summary>
private int[][] BuildTransitionTable(BitSet firstpos, BitSet[] followpos, int endMarkerPos) {
const int TimeConstant = 8192; //(MaxStates * MaxPositions should be a constant)
int positionsCount = positions.Count;
int MaxStatesCount = TimeConstant / positionsCount;
int symbolsCount = symbols.Count;
// transition table (Dtran in the book)
ArrayList transitionTable = new ArrayList();
// state lookup table (Dstate in the book)
Hashtable stateTable = new Hashtable();
// Add empty set that would signal an error
stateTable.Add(new BitSet(positionsCount), -1);
// lists unmarked states
Queue unmarked = new Queue();
// initially, the only unmarked state in Dstates is firstpo(root)
int state = 0;
unmarked.Enqueue(firstpos);
stateTable.Add(firstpos, 0);
transitionTable.Add(new int[symbolsCount + 1]);
// while there is an umnarked state T in Dstates do begin
while (unmarked.Count > 0) {
BitSet statePosSet = (BitSet)unmarked.Dequeue(); // all positions that constitute DFA state
Debug.Assert(state == (int)stateTable[statePosSet]); // just make sure that statePosSet is for correct state
int[] transition = (int[])transitionTable[state];
if (statePosSet[endMarkerPos]) {
transition[symbolsCount] = 1; // accepting
}
// for each input symbol a do begin
for (int symbol = 0; symbol < symbolsCount; symbol ++) {
// let U be the set of positions that are in followpos(p)
// for some position p in T
// such that the symbol at position p is a
BitSet newset = new BitSet(positionsCount);
for (int pos = statePosSet.NextSet(-1); pos != -1; pos = statePosSet.NextSet(pos)) {
if (symbol == positions[pos].symbol) {
newset.Or(followpos[pos]);
}
}
// if U is not empty and is not in Dstates then
// add U as an unmarked state to Dstates
object lookup = stateTable[newset];
if (lookup != null) {
transition[symbol] = (int)lookup;
}
else {
// construct new state
int newState = stateTable.Count - 1;
if (newState >= MaxStatesCount) {
return null;
}
unmarked.Enqueue(newset);
stateTable.Add(newset, newState);
transitionTable.Add(new int[symbolsCount + 1]);
transition[symbol] = newState;
}
}
state++;
}
// now convert transition table to array
return (int[][])transitionTable.ToArray(typeof(int[]));
}
示例8: Finish
internal void Finish(ValidationEventHandler eventHandler, bool compile) {
stack = null;
IsCompiled = !abnormalContent && compile;
if (contentNode == null)
return;
#if DEBUG
StringBuilder bb = new StringBuilder();
contentNode.Dump(bb);
Debug.WriteLineIf(CompModSwitches.XmlSchema.TraceVerbose, "\t\t\tContent: (" + bb.ToString() + ")");
#endif
// add end node
endNode = NewTerminalNode(XmlQualifiedName.Empty);
contentNode = new InternalNode(contentNode, endNode, ContentNode.Type.Sequence);
((InternalNode)contentNode).LeftNode.ParentNode = contentNode;
endNode.ParentNode = contentNode;
if (!IsCompiled) {
CheckXsdDeterministic(eventHandler);
return;
}
if (nodeTable == null)
nodeTable = new Hashtable();
// calculate followpos
int terminals = terminalNodes.Count;
BitSet[] followpos = new BitSet[terminals];
for (int i = 0; i < terminals; i++) {
followpos[i] = new BitSet(terminals);
}
contentNode.CalcFollowpos(followpos);
// state table
ArrayList Dstates = new ArrayList(16);
// transition table
dtrans = new ArrayList(16);
// lists unmarked states
ArrayList unmarked = new ArrayList(16);
// state lookup table
Hashtable statetable = new Hashtable();
BitSet empty = new BitSet(terminals);
statetable.Add(empty, -1);
// start with firstpos at the root
BitSet set = contentNode.Firstpos(terminals);
statetable.Add(set, Dstates.Count);
unmarked.Add(set);
Dstates.Add(set);
int[] a = new int[symbols.Count + 1];
dtrans.Add(a);
if (set.Get(endNode.Pos)) {
a[symbols.Count] = 1; // accepting
}
// current state processed
int state = 0;
// check all unmarked states
while (unmarked.Count > 0) {
int[] t = (int[])dtrans[state];
set = (BitSet)unmarked[0];
CheckDeterministic(set, terminals, eventHandler);
unmarked.RemoveAt(0);
// check all input symbols
for (int sym = 0; sym < symbols.Count; sym++) {
XmlQualifiedName n = (XmlQualifiedName)symbols[sym];
BitSet newset = new BitSet(terminals);
// if symbol is in the set add followpos to new set
for (int i = 0; i < terminals; i++) {
if (set.Get(i) && n.Equals(((TerminalNode)terminalNodes[i]).Name)) {
newset.Or(followpos[i]);
}
}
Object lookup = statetable[newset];
// this state will transition to
int transitionTo;
// if new set is not in states add it
if (lookup == null) {
transitionTo = Dstates.Count;
statetable.Add(newset, transitionTo);
unmarked.Add(newset);
Dstates.Add(newset);
a = new int[symbols.Count + 1];
dtrans.Add(a);
if (newset.Get(endNode.Pos)) {
a[symbols.Count] = 1; // accepting
}
}
else {
transitionTo = (int)lookup;
}
// set the transition for the symbol
//.........这里部分代码省略.........
示例9: CalculateTotalFollowposForRangeNodes
private BitSet[] CalculateTotalFollowposForRangeNodes(BitSet firstpos, BitSet[] followpos, out BitSet posWithRangeTerminals) {
int positionsCount = positions.Count; //terminals
posWithRangeTerminals = new BitSet(positionsCount);
//Compute followpos for each range node
//For any range node that is surrounded by an outer range node, its follow positions will include those of the outer range node
BitSet[] minmaxFollowPos = new BitSet[minMaxNodesCount];
int localMinMaxNodesCount = 0;
for (int i = positionsCount - 1; i >= 0; i--) {
Position p = positions[i];
if (p.symbol == -2) { //P is a LeafRangeNode
LeafRangeNode lrNode = p.particle as LeafRangeNode;
Debug.Assert(lrNode != null);
BitSet tempFollowPos = new BitSet(positionsCount);
tempFollowPos.Clear();
tempFollowPos.Or(followpos[i]); //Add the followpos of the range node
if (lrNode.Min != lrNode.Max) { //If they are the same, then followpos cannot include the firstpos
tempFollowPos.Or(lrNode.NextIteration); //Add the nextIteration of the range node (this is the firstpos of its parent's leftChild)
}
//For each position in the bitset, if it is a outer range node (pos > i), then add its followpos as well to the current node's followpos
for (int pos = tempFollowPos.NextSet(-1); pos != -1; pos = tempFollowPos.NextSet(pos)) {
if (pos > i) {
Position p1 = positions[pos];
if (p1.symbol == -2) {
LeafRangeNode lrNode1 = p1.particle as LeafRangeNode;
Debug.Assert(lrNode1 != null);
tempFollowPos.Or(minmaxFollowPos[lrNode1.Pos]);
}
}
}
//set the followpos built to the index in the BitSet[]
minmaxFollowPos[localMinMaxNodesCount] = tempFollowPos;
lrNode.Pos = localMinMaxNodesCount++;
posWithRangeTerminals.Set(i);
}
}
return minmaxFollowPos;
}
示例10: BuildTransitionTable
private int[][] BuildTransitionTable(BitSet firstpos, BitSet[] followpos, int endMarkerPos)
{
int count = this.positions.Count;
int num2 = 0x2000 / count;
int index = this.symbols.Count;
ArrayList list = new ArrayList();
Hashtable hashtable = new Hashtable();
hashtable.Add(new BitSet(count), -1);
Queue queue = new Queue();
int num4 = 0;
queue.Enqueue(firstpos);
hashtable.Add(firstpos, 0);
list.Add(new int[index + 1]);
while (queue.Count > 0)
{
BitSet set = (BitSet) queue.Dequeue();
int[] numArray = (int[]) list[num4];
if (set[endMarkerPos])
{
numArray[index] = 1;
}
for (int i = 0; i < index; i++)
{
BitSet set2 = new BitSet(count);
for (int j = set.NextSet(-1); j != -1; j = set.NextSet(j))
{
if (i == this.positions[j].symbol)
{
set2.Or(followpos[j]);
}
}
object obj2 = hashtable[set2];
if (obj2 != null)
{
numArray[i] = (int) obj2;
}
else
{
int num7 = hashtable.Count - 1;
if (num7 >= num2)
{
return null;
}
queue.Enqueue(set2);
hashtable.Add(set2, num7);
list.Add(new int[index + 1]);
numArray[i] = num7;
}
}
num4++;
}
return (int[][]) list.ToArray(typeof(int[]));
}
示例11: GetApplicableMinMaxFollowPos
private BitSet GetApplicableMinMaxFollowPos(BitSet curpos, BitSet posWithRangeTerminals, BitSet[] minmaxFollowPos)
{
if (curpos.Intersects(posWithRangeTerminals))
{
BitSet set = new BitSet(this.positions.Count);
set.Or(curpos);
set.And(posWithRangeTerminals);
curpos = curpos.Clone();
for (int i = set.NextSet(-1); i != -1; i = set.NextSet(i))
{
LeafRangeNode particle = this.positions[i].particle as LeafRangeNode;
curpos.Or(minmaxFollowPos[particle.Pos]);
}
}
return curpos;
}
示例12: CalculateTotalFollowposForRangeNodes
private BitSet[] CalculateTotalFollowposForRangeNodes(BitSet firstpos, BitSet[] followpos, out BitSet posWithRangeTerminals)
{
int count = this.positions.Count;
posWithRangeTerminals = new BitSet(count);
BitSet[] setArray = new BitSet[this.minMaxNodesCount];
int index = 0;
for (int i = count - 1; i >= 0; i--)
{
Position position = this.positions[i];
if (position.symbol == -2)
{
LeafRangeNode particle = position.particle as LeafRangeNode;
BitSet set = new BitSet(count);
set.Clear();
set.Or(followpos[i]);
if (particle.Min != particle.Max)
{
set.Or(particle.NextIteration);
}
for (int j = set.NextSet(-1); j != -1; j = set.NextSet(j))
{
if (j > i)
{
Position position2 = this.positions[j];
if (position2.symbol == -2)
{
LeafRangeNode node2 = position2.particle as LeafRangeNode;
set.Or(setArray[node2.Pos]);
}
}
}
setArray[index] = set;
particle.Pos = index++;
posWithRangeTerminals.Set(i);
}
}
return setArray;
}
示例13: ConstructPos
public override void ConstructPos(BitSet firstpos, BitSet lastpos, BitSet[] followpos) {
LeftChild.ConstructPos(firstpos, lastpos, followpos);
BitSet firstposRight = new BitSet(firstpos.Count);
BitSet lastposRight = new BitSet(lastpos.Count);
RightChild.ConstructPos(firstposRight, lastposRight, followpos);
firstpos.Or(firstposRight);
lastpos.Or(lastposRight);
}