public override string ToString() { string representation = "Integer: "; MCircularListNode <bool> node = list.firstNode; if (node != null) { while (true) { if (node.nodeValue) { representation += "1"; } else { representation += "0"; } if (object.ReferenceEquals(node, list.lastNode)) { return(representation); } else { node = node.nextNode; } } } return(representation); }
public MInteger Next() { if (IsNull()) { return(Append(true)); } MCircularListNode <bool> node = list.firstNode; while (true) { if (node.nodeValue) { node.nodeValue = false; } else { node.nodeValue = true; return(this); } if (object.ReferenceEquals(node, list.lastNode)) { return(Append(true)); } node = node.nextNode; } }
public byte GetByte(MInteger index) { if (IsNull()) { return(0); } MCircularListNode <bool> node = list.firstNode; MInteger counter = new MInteger(); bool iterate = true; while (iterate) { if (counter.Equals(index)) { iterate = false; } else { if (object.ReferenceEquals(node, list.lastNode)) { return(0); } node = node.nextNode; } } MInteger limit = new MInteger("8"); counter = new MInteger(); byte result = 0; byte adder = 1; while (true) { if (counter.Equals(index)) { return(result); } if (object.ReferenceEquals(node, list.lastNode)) { return(result); } if (node.nodeValue) { result += adder; } adder *= 2; node = node.nextNode; } }
public MInteger Append(MInteger integer) { if (integer.IsNull()) { return(this); } MCircularListNode <bool> node = integer.list.firstNode; while (true) { Append(node.nodeValue); if (object.ReferenceEquals(node, integer.list.lastNode)) { return(this); } node = node.nextNode; } }