本文整理汇总了C#中BlockList类的典型用法代码示例。如果您正苦于以下问题:C# BlockList类的具体用法?C# BlockList怎么用?C# BlockList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BlockList类属于命名空间,在下文中一共展示了BlockList类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GameState
public GameState()
{
Blocks = new BlockList();
Effects = new EffectList();
Units = new UnitList();
Projectiles = new ProjectileList();
}
开发者ID:EttienneS,项目名称:Contingency,代码行数:7,代码来源:GameState.cs
示例2: GameWorld
public GameWorld(int width, int height, ContentManager Content)
{
screenWidth = width;
screenHeight = height;
random = new Random();
gameState = GameState.Menu;
inputHelper = new InputHelper();
block = Content.Load<Texture2D>("block");
reset = Content.Load<Texture2D>("reset");
font = Content.Load<SpriteFont>("SpelFont");
font2 = Content.Load<SpriteFont>("SpriteFont1");
font3 = Content.Load<SpriteFont>("SpriteFont2");
playButton = Content.Load<Texture2D>("Play");
optionsButton = Content.Load<Texture2D>("Options");
backButton = Content.Load<Texture2D>("Back");
polytris = Content.Load<Texture2D>("Polytris");
grid = new TetrisGrid(block);
level = 1;
levelspeed = 1;
score = 0;
i = (int)random.Next(7) + 1;
i2 = (int)random.Next(7) + 1;
blockcounter = 1;
blocks = new BlockList(block, Content); //Voegen de verschillende blockobjecten toe aan de lijst
block1 = new Block1(block, Content);
blocks.Add(block1, 1);
block2 = new Block2(block, Content);
blocks.Add(block2, 2);
block3 = new Block3(block, Content);
blocks.Add(block3, 3);
block4 = new Block4(block, Content);
blocks.Add(block4, 4);
block5 = new Block5(block, Content);
blocks.Add(block5, 5);
block6 = new Block6(block, Content);
blocks.Add(block6, 6);
block7 = new Block7(block, Content);
blocks.Add(block7, 7);
//Voegen de verschillende blockobjecten toe aan een tweede lijst voor het tekenen van het volgende blokje
block1res = new Block1(block, Content);
blocks.AddToReserve(block1res, 1);
block2res = new Block2(block, Content);
blocks.AddToReserve(block2res, 2);
block3res = new Block3(block, Content);
blocks.AddToReserve(block3res, 3);
block4res = new Block4(block, Content);
blocks.AddToReserve(block4res, 4);
block5res = new Block5(block, Content);
blocks.AddToReserve(block5res, 5);
block6res = new Block6(block, Content);
blocks.AddToReserve(block6res, 6);
block7res = new Block7(block, Content);
blocks.AddToReserve(block7res, 7);
options = new Options(block, reset, backButton, width, height, font, blocks);
menu = new Menu(playButton, optionsButton, polytris, width, height);
gameOver = new GameOver(backButton, width, height);
}
开发者ID:Supercarlijn,项目名称:Tetris,代码行数:60,代码来源:GameWorld.cs
示例3: TestGet
public virtual void TestGet()
{
BlockList<string> list = new BlockList<string>(4);
string b;
try
{
b = list[-1];
}
catch (IndexOutOfRangeException badIndex)
{
NUnit.Framework.Assert.AreEqual((-1).ToString(), badIndex.Message);
}
try
{
b = list[0];
}
catch (IndexOutOfRangeException badIndex)
{
NUnit.Framework.Assert.AreEqual(0.ToString(), badIndex.Message);
}
try
{
b = list[4];
}
catch (IndexOutOfRangeException badIndex)
{
NUnit.Framework.Assert.AreEqual(4.ToString(), badIndex.Message);
}
string fooStr = "foo";
string barStr = "bar";
string foobarStr = "foobar";
list.AddItem(fooStr);
list.AddItem(barStr);
list.AddItem(foobarStr);
NUnit.Framework.Assert.AreSame(fooStr, list[0]);
NUnit.Framework.Assert.AreSame(barStr, list[1]);
NUnit.Framework.Assert.AreSame(foobarStr, list[2]);
try
{
b = list[3];
}
catch (IndexOutOfRangeException badIndex)
{
NUnit.Framework.Assert.AreEqual(3.ToString(), badIndex.Message);
}
}
开发者ID:LunarLanding,项目名称:ngit,代码行数:46,代码来源:BlockListTest.cs
示例4: Options
public Options(Texture2D blockSprite, Texture2D resetSprite, Texture2D backSprite, int screenWidth, int screenHeight, SpriteFont spriteFont, BlockList blocks)
{
block = blockSprite;
reset = resetSprite;
back = backSprite;
this.screenWidth = screenWidth;
this.screenHeight = screenHeight;
this.blocks = blocks;
block1 = blocks.Find(1);
block2 = blocks.Find(2);
block3 = blocks.Find(3);
block4 = blocks.Find(4);
block5 = blocks.Find(5);
block6 = blocks.Find(6);
block7 = blocks.Find(7);
font = spriteFont;
backRect = new Rectangle(screenWidth / 2 - backSprite.Width / 2, screenHeight - backSprite.Height - 100, backSprite.Width, backSprite.Height);
}
开发者ID:Supercarlijn,项目名称:Tetris,代码行数:18,代码来源:Options.cs
示例5: TestEmptyList
public virtual void TestEmptyList()
{
BlockList<string> empty;
empty = new BlockList<string>();
NUnit.Framework.Assert.AreEqual(0, empty.Count);
NUnit.Framework.Assert.IsTrue(empty.IsEmpty());
NUnit.Framework.Assert.IsFalse(empty.Iterator().HasNext());
empty = new BlockList<string>(0);
NUnit.Framework.Assert.AreEqual(0, empty.Count);
NUnit.Framework.Assert.IsTrue(empty.IsEmpty());
NUnit.Framework.Assert.IsFalse(empty.Iterator().HasNext());
empty = new BlockList<string>(1);
NUnit.Framework.Assert.AreEqual(0, empty.Count);
NUnit.Framework.Assert.IsTrue(empty.IsEmpty());
NUnit.Framework.Assert.IsFalse(empty.Iterator().HasNext());
empty = new BlockList<string>(64);
NUnit.Framework.Assert.AreEqual(0, empty.Count);
NUnit.Framework.Assert.IsTrue(empty.IsEmpty());
NUnit.Framework.Assert.IsFalse(empty.Iterator().HasNext());
}
开发者ID:LunarLanding,项目名称:ngit,代码行数:20,代码来源:BlockListTest.cs
示例6: Run
public double Run(double[] data, int detailLevel)
{
var sb = new StringBuilder();
for (int i = 0; i < data.Length; i++)
{
sb.Append(data[i]);
if (i < data.Length - 1) sb.Append(",");
}
string datastring = sb.ToString();
var textBlock = new ImportFromTextBlock
{
Text = datastring,
ColumnSeparator = ",",
SignalStart = 0,
SignalNameInFirstColumn = false
};
var dwtBlock = new DWTBlock
{
WaveletName = "db10",
Level = detailLevel,
ExtensionMode = SignalExtension.ExtensionMode.ZeroPadding
};
var b = new BlockList();
b.Add(textBlock);
b.Add(dwtBlock);
textBlock.ConnectTo(dwtBlock);
b.ExecuteAll();
int length = dwtBlock.OutputNodes[dwtBlock.OutputNodes.Count-1].Object[detailLevel - 1].Samples.Length;
double val = dwtBlock.OutputNodes[dwtBlock.OutputNodes.Count-1].Object[detailLevel - 1].Samples[length - 1];
return val;
}
开发者ID:ifzz,项目名称:QuantSys,代码行数:41,代码来源:SignalTransform.cs
示例7: TestAddRejectsBadIndexes
public virtual void TestAddRejectsBadIndexes()
{
BlockList<int> list = new BlockList<int>(4);
list.AddItem(Sharpen.Extensions.ValueOf(41));
try
{
list.Add(-1, Sharpen.Extensions.ValueOf(42));
}
catch (IndexOutOfRangeException badIndex)
{
NUnit.Framework.Assert.AreEqual((-1).ToString(), badIndex.Message);
}
try
{
list.Add(4, Sharpen.Extensions.ValueOf(42));
}
catch (IndexOutOfRangeException badIndex)
{
NUnit.Framework.Assert.AreEqual(4.ToString(), badIndex.Message);
}
}
开发者ID:ashmind,项目名称:ngit,代码行数:21,代码来源:BlockListTest.cs
示例8: FFTTransform
public static List<double> FFTTransform(List<double> serie)
{
//Declaring the blocks
var inputSeriesBlock = new InputSeriesBlock();
inputSeriesBlock.SetSeries(serie);
var outputSeriesBlock = new OutputSeriesBlock();
var fFTBlock = new FFTBlock
{
Mode = ManagedFFTModeEnum.UseLookupTable
};
//Connecting the blocks
inputSeriesBlock.OutputNodes[0].ConnectTo(fFTBlock.InputNodes[0]);
fFTBlock.OutputNodes[1].ConnectTo(outputSeriesBlock.InputNodes[0]);
//Appending the blocks to a block list and execute all
var blockList = new BlockList();
blockList.Add(inputSeriesBlock);
blockList.Add(fFTBlock);
blockList.Add(outputSeriesBlock);
blockList.ExecuteAll();
return outputSeriesBlock.GetSeries();
}
开发者ID:Bruhankovi4,项目名称:Emotyper,代码行数:21,代码来源:DataTransformations.cs
示例9: BlockAllocationTableReader
/// <summary>
/// create a BlockAllocationTableReader for an existing filesystem. Side
/// effect: when this method finishes, the BAT blocks will have
/// been Removed from the raw block list, and any blocks labeled as
/// 'unused' in the block allocation table will also have been
/// Removed from the raw block list. </summary>
/// <param name="bigBlockSizse">the poifs bigBlockSize</param>
/// <param name="block_count">the number of BAT blocks making up the block allocation table</param>
/// <param name="block_array">the array of BAT block indices from the
/// filesystem's header</param>
/// <param name="xbat_count">the number of XBAT blocks</param>
/// <param name="xbat_index">the index of the first XBAT block</param>
/// <param name="raw_block_list">the list of RawDataBlocks</param>
public BlockAllocationTableReader(POIFSBigBlockSize bigBlockSizse,
int block_count,
int[] block_array,
int xbat_count,
int xbat_index,
BlockList raw_block_list)
: this(bigBlockSizse)
{
SanityCheckBlockCount(block_count);
RawDataBlock[] blocks = new RawDataBlock[block_count];
int limit = Math.Min(block_count, block_array.Length);
int block_index;
for (block_index = 0; block_index < limit; block_index++)
{
int nextOffset = block_array[block_index];
if (nextOffset > raw_block_list.BlockCount())
{
throw new IOException("Your file contains " + raw_block_list.BlockCount() +
" sectors, but the initial DIFAT array at index " + block_index +
" referenced block # " + nextOffset + ". This isn't allowed and " +
" your file is corrupt");
}
blocks[block_index] = (RawDataBlock)raw_block_list.Remove(nextOffset);
}
if (block_index < block_count)
{
// must have extended blocks
if (xbat_index < 0)
{
throw new IOException(
"BAT count exceeds limit, yet XBAT index indicates no valid entries");
}
int chain_index = xbat_index;
int max_entries_per_block = BATBlock.EntriesPerXBATBlock;
int chain_index_offset = BATBlock.XBATChainOffset;
// Each XBAT block contains either:
// (maximum number of sector indexes) + index of next XBAT
// some sector indexes + FREE sectors to max # + EndOfChain
for (int j = 0; j < xbat_count; j++)
{
limit = Math.Min(block_count - block_index,
max_entries_per_block);
byte[] data = raw_block_list.Remove(chain_index).Data;
int offset = 0;
for (int k = 0; k < limit; k++)
{
blocks[block_index++] =
(RawDataBlock)raw_block_list.Remove(LittleEndian.GetInt(data, offset));
offset += LittleEndianConsts.INT_SIZE;
}
chain_index = LittleEndian.GetInt(data, chain_index_offset);
if (chain_index == POIFSConstants.END_OF_CHAIN)
{
break;
}
}
}
if (block_index != block_count)
{
throw new IOException("Could not find all blocks");
}
// now that we have all of the raw data blocks, go through and
// create the indices
SetEntries((ListManagedBlock[])blocks, raw_block_list);
}
开发者ID:xiepeixing,项目名称:npoi,代码行数:85,代码来源:BlockAllocationTableReader.cs
示例10: FetchBlocks
/// <summary>
/// walk the entries from a specified point and return the
/// associated blocks. The associated blocks are Removed from the block list
/// </summary>
/// <param name="startBlock">the first block in the chain</param>
/// <param name="headerPropertiesStartBlock"></param>
/// <param name="blockList">the raw data block list</param>
/// <returns>array of ListManagedBlocks, in their correct order</returns>
public ListManagedBlock[] FetchBlocks(int startBlock, int headerPropertiesStartBlock,
BlockList blockList)
{
List<ListManagedBlock> blocks = new List<ListManagedBlock>();
int currentBlock = startBlock;
bool firstPass = true;
ListManagedBlock dataBlock = null;
while (currentBlock != POIFSConstants.END_OF_CHAIN)
{
try
{
dataBlock = blockList.Remove(currentBlock);
blocks.Add(dataBlock);
currentBlock = _entries[currentBlock];
firstPass = false;
}
catch(Exception)
{
if (currentBlock == headerPropertiesStartBlock)
{
// Special case where things are in the wrong order
_logger.Log(POILogger.WARN, "Warning, header block comes after data blocks in POIFS block listing");
currentBlock = POIFSConstants.END_OF_CHAIN;
}
else if (currentBlock == 0 && firstPass)
{
// Special case where the termination isn't done right
// on an empty set
_logger.Log(POILogger.WARN, "Warning, incorrectly terminated empty data blocks in POIFS block listing (should end at -2, ended at 0)");
currentBlock = POIFSConstants.END_OF_CHAIN;
}
else
{
// Ripple up
throw;
}
}
}
ListManagedBlock[] array = blocks.ToArray();
return (array);
}
开发者ID:xiepeixing,项目名称:npoi,代码行数:50,代码来源:BlockAllocationTableReader.cs
示例11: VisitSwitch
protected override object VisitSwitch(Variable selector, BlockList targets, Statement stat, object arg) {
InitializedVariables iv=(InitializedVariables)arg;
CheckUse(iv, selector, stat);
return arg;
}
开发者ID:tapicer,项目名称:resource-contracts-.net,代码行数:5,代码来源:DefiniteAssignmentAnalysis.cs
示例12: Parse
/// <summary>Parse the pack stream.</summary>
/// <remarks>Parse the pack stream.</remarks>
/// <param name="receiving">
/// receives progress feedback during the initial receiving
/// objects phase. If null,
/// <see cref="NGit.NullProgressMonitor">NGit.NullProgressMonitor</see>
/// will be
/// used.
/// </param>
/// <param name="resolving">receives progress feedback during the resolving objects phase.
/// </param>
/// <returns>
/// the pack lock, if one was requested by setting
/// <see cref="SetLockMessage(string)">SetLockMessage(string)</see>
/// .
/// </returns>
/// <exception cref="System.IO.IOException">the stream is malformed, or contains corrupt objects.
/// </exception>
public virtual PackLock Parse(ProgressMonitor receiving, ProgressMonitor resolving
)
{
if (receiving == null)
{
receiving = NullProgressMonitor.INSTANCE;
}
if (resolving == null)
{
resolving = NullProgressMonitor.INSTANCE;
}
if (receiving == resolving)
{
receiving.Start(2);
}
try
{
ReadPackHeader();
entries = new PackedObjectInfo[(int)objectCount];
baseById = new ObjectIdOwnerMap<PackParser.DeltaChain>();
baseByPos = new LongMap<PackParser.UnresolvedDelta>();
deferredCheckBlobs = new BlockList<PackedObjectInfo>();
receiving.BeginTask(JGitText.Get().receivingObjects, (int)objectCount);
try
{
for (int done = 0; done < objectCount; done++)
{
IndexOneObject();
receiving.Update(1);
if (receiving.IsCancelled())
{
throw new IOException(JGitText.Get().downloadCancelled);
}
}
ReadPackFooter();
EndInput();
}
finally
{
receiving.EndTask();
}
if (!deferredCheckBlobs.IsEmpty())
{
DoDeferredCheckBlobs();
}
if (deltaCount > 0)
{
if (resolving is BatchingProgressMonitor)
{
((BatchingProgressMonitor)resolving).SetDelayStart(1000, TimeUnit.MILLISECONDS);
}
resolving.BeginTask(JGitText.Get().resolvingDeltas, deltaCount);
ResolveDeltas(resolving);
if (entryCount < objectCount)
{
if (!IsAllowThin())
{
throw new IOException(MessageFormat.Format(JGitText.Get().packHasUnresolvedDeltas
, Sharpen.Extensions.ValueOf(objectCount - entryCount)));
}
ResolveDeltasWithExternalBases(resolving);
if (entryCount < objectCount)
{
throw new IOException(MessageFormat.Format(JGitText.Get().packHasUnresolvedDeltas
, Sharpen.Extensions.ValueOf(objectCount - entryCount)));
}
}
resolving.EndTask();
}
packDigest = null;
baseById = null;
baseByPos = null;
}
finally
{
try
{
if (readCurs != null)
{
readCurs.Release();
}
}
//.........这里部分代码省略.........
开发者ID:LunarLanding,项目名称:ngit,代码行数:101,代码来源:PackParser.cs
示例13: VisitBlockList
public virtual Differences VisitBlockList(BlockList list1, BlockList list2,
out BlockList changes, out BlockList deletions, out BlockList insertions){
changes = list1 == null ? null : list1.Clone();
deletions = list1 == null ? null : list1.Clone();
insertions = list1 == null ? new BlockList() : list1.Clone();
//^ assert insertions != null;
Differences differences = new Differences();
for (int j = 0, n = list2 == null ? 0 : list2.Count; j < n; j++){
//^ assert list2 != null;
Block nd2 = list2[j];
if (nd2 == null) continue;
insertions.Add(null);
}
TrivialHashtable savedDifferencesMapFor = this.differencesMapFor;
this.differencesMapFor = null;
TrivialHashtable matchedNodes = new TrivialHashtable();
for (int i = 0, k = 0, n = list1 == null ? 0 : list1.Count; i < n; i++){
//^ assert list1 != null && changes != null && deletions != null;
Block nd1 = list1[i];
if (nd1 == null) continue;
Differences diff;
int j;
Block nd2 = this.GetClosestMatch(nd1, list1, list2, i, ref k, matchedNodes, out diff, out j);
if (nd2 == null || diff == null){Debug.Assert(nd2 == null && diff == null); continue;}
matchedNodes[nd1.UniqueKey] = nd1;
matchedNodes[nd2.UniqueKey] = nd2;
changes[i] = diff.Changes as Block;
deletions[i] = diff.Deletions as Block;
insertions[i] = diff.Insertions as Block;
insertions[n+j] = nd1; //Records the position of nd2 in list2 in case the change involved a permutation
Debug.Assert(diff.Changes == changes[i] && diff.Deletions == deletions[i] && diff.Insertions == insertions[i]);
differences.NumberOfDifferences += diff.NumberOfDifferences;
differences.NumberOfSimilarities += diff.NumberOfSimilarities;
}
//Find deletions
for (int i = 0, n = list1 == null ? 0 : list1.Count; i < n; i++){
//^ assert list1 != null && changes != null && deletions != null;
Block nd1 = list1[i];
if (nd1 == null) continue;
if (matchedNodes[nd1.UniqueKey] != null) continue;
changes[i] = null;
deletions[i] = nd1;
insertions[i] = null;
differences.NumberOfDifferences += 1;
}
//Find insertions
for (int j = 0, n = list1 == null ? 0 : list1.Count, m = list2 == null ? 0 : list2.Count; j < m; j++){
//^ assert list2 != null;
Block nd2 = list2[j];
if (nd2 == null) continue;
if (matchedNodes[nd2.UniqueKey] != null) continue;
insertions[n+j] = nd2; //Records nd2 as an insertion into list1, along with its position in list2
differences.NumberOfDifferences += 1; //REVIEW: put the size of the tree here?
}
if (differences.NumberOfDifferences == 0){
changes = null;
deletions = null;
insertions = null;
}
this.differencesMapFor = savedDifferencesMapFor;
return differences;
}
开发者ID:tapicer,项目名称:resource-contracts-.net,代码行数:62,代码来源:Comparer.cs
示例14: VisitBlockList
public virtual BlockList VisitBlockList(BlockList blockList)
{
if (blockList == null) return null;
for (int i = 0, n = blockList.Count; i < n; i++)
blockList[i] = this.VisitBlock(blockList[i]);
return blockList;
}
开发者ID:julianhaslinger,项目名称:SHFB,代码行数:7,代码来源:StandardVisitor.cs
示例15: FetchBlocks
/// <summary>
/// walk the entries from a specified point and return the
/// associated blocks. The associated blocks are Removed from the block list
/// </summary>
/// <param name="startBlock">the first block in the chain</param>
/// <param name="blockList">the raw data block list</param>
/// <returns>array of ListManagedBlocks, in their correct order</returns>
public ListManagedBlock[] FetchBlocks(int startBlock,
BlockList blockList)
{
IList blocks = new ArrayList();
int currentBlock = startBlock;
while (currentBlock != POIFSConstants.END_OF_CHAIN)
{
blocks.Add(blockList.Remove(currentBlock));
currentBlock = _entries[currentBlock];
}
ListManagedBlock[] array = new ListManagedBlock[blocks.Count];
blocks.CopyTo(array, 0);
return (array);
}
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:23,代码来源:BlockAllocationTableReader.cs
示例16: BlockAllocationTableReader
/// <summary>
/// create a BlockAllocationTableReader for an existing filesystem. Side
/// effect: when this method finishes, the BAT blocks will have
/// been Removed from the raw block list, and any blocks labeled as
/// 'unused' in the block allocation table will also have been
/// Removed from the raw block list. </summary>
/// <param name="block_count">the number of BAT blocks making up the block allocation table</param>
/// <param name="block_array">the array of BAT block indices from the
/// filesystem's header</param>
/// <param name="xbat_count">the number of XBAT blocks</param>
/// <param name="xbat_index">the index of the first XBAT block</param>
/// <param name="raw_block_list">the list of RawDataBlocks</param>
public BlockAllocationTableReader(int block_count,
int[] block_array,
int xbat_count,
int xbat_index,
BlockList raw_block_list)
: this()
{
if (block_count <= 0)
{
throw new IOException(
"Illegal block count; minimum count is 1, got " + block_count
+ " instead");
}
// acquire raw data blocks containing the BAT block data
RawDataBlock[] blocks = new RawDataBlock[block_count];
int limit = Math.Min(block_count, block_array.Length);
int block_index;
for (block_index = 0; block_index < limit; block_index++)
{
blocks[block_index] =
(RawDataBlock)raw_block_list
.Remove(block_array[block_index]);
}
if (block_index < block_count)
{
// must have extended blocks
if (xbat_index < 0)
{
throw new IOException(
"BAT count exceeds limit, yet XBAT index indicates no valid entries");
}
int chain_index = xbat_index;
int max_entries_per_block = BATBlock.EntriesPerXBATBlock;
int chain_index_offset = BATBlock.XBATChainOffset;
for (int j = 0; j < xbat_count; j++)
{
limit = Math.Min(block_count - block_index,
max_entries_per_block);
byte[] data = raw_block_list.Remove(chain_index).Data;
int offset = 0;
for (int k = 0; k < limit; k++)
{
blocks[block_index++] =
(RawDataBlock)raw_block_list
.Remove(LittleEndian.GetInt(data, offset));
offset += LittleEndianConstants.INT_SIZE;
}
chain_index = LittleEndian.GetInt(data, chain_index_offset);
if (chain_index == POIFSConstants.END_OF_CHAIN)
{
break;
}
}
}
if (block_index != block_count)
{
throw new IOException("Could not find all blocks");
}
// now that we have all of the raw data blocks, go through and
// create the indices
SetEntries((ListManagedBlock[])blocks, raw_block_list);
}
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:81,代码来源:BlockAllocationTableReader.cs
示例17: VisitSwitch
protected override object VisitSwitch (Variable selector, BlockList Targets, Statement stat, object arg)
{
return "SWITCH (" + CciHelper.Name(selector) + ")";
}
开发者ID:hesam,项目名称:SketchSharp,代码行数:4,代码来源:InstructionVisitor.cs
示例18: GetClosestMatch
public virtual Block GetClosestMatch(Block/*!*/ nd1, BlockList/*!*/ list1, BlockList list2, int list1pos, ref int list2start,
TrivialHashtable/*!*/ matchedNodes, out Differences closestDifferences, out int list2pos) {
closestDifferences = null; list2pos = -1;
if (list2 == null) return null;
if (nd1 == null || list1 == null || matchedNodes == null || list1pos < 0 || list1pos >= list1.Count || list2start < 0 || list2start >= list2.Count) {
Debug.Assert(false); return null;
}
Block closest = null;
Differences winnerSoFar = null;
for (int j = list2start, m = list2.Count; j < m; j++){
Block nd2 = list2[j];
if (list2start == j) list2start++;
if (nd2 == null) continue;
if (matchedNodes[nd2.UniqueKey] != null) continue;
Differences diff = this.GetDifferences(nd1, nd2);
if (diff == null){Debug.Assert(false); continue;}
if (diff.Similarity <= 0.5){
//Not a good enough match
if (list2start == j+1) list2start--; //The next call to GetClosestMatch will start looking at list2start, so this node will be considered then
continue; //ignore it for the rest of this call
}
if (winnerSoFar != null && winnerSoFar.Similarity >= diff.Similarity) continue;
winnerSoFar = closestDifferences = diff;
closest = nd2;
list2pos = j;
if (diff.NumberOfDifferences == 0) return closest; //Perfect match, no need to look for other matches
}
if (closest != null){
//^ assert winnerSoFar != null;
//closest is closer to nd1 than any other node in list2, but this is no good if some other node in list1 has a better claim on closest
for (int i = list1pos+1, n = list1.Count; i < n; i++){
Block nd1alt = list1[i];
if (nd1alt == null) continue;
if (matchedNodes[nd1alt.UniqueKey] != null) continue;
Differences diff = this.GetDifferences(nd1alt, closest);
if (diff == null){Debug.Assert(false); continue;}
if (diff.Similarity <= winnerSoFar.Similarity) continue;
//nd1alt has a better claim on closest. See if it wants closest.
Differences diff2;
int j, k = list2start;
Block nd2alt = this.GetClosestMatch(nd1alt, list1, list2, i, ref k, matchedNodes, out diff2, out j);
if (nd2alt != closest){
Debug.Assert(nd2alt != null && diff2 != null && diff2.Similarity >= diff.Similarity);
continue; //nd1alt prefers nd2alt to closest, so closest is still available
}
//nd1alt wants closest, take it out of the running
matchedNodes[closest.UniqueKey] = nd1alt;
//Now that closest is out of the running, try again
k = list2start;
Block newClosest = this.GetClosestMatch(nd1, list1, list2, i, ref k, matchedNodes, out winnerSoFar, out list2pos);
//put closest back in the running so that the next call to this routine will pick it up
matchedNodes[closest.UniqueKey] = closest;
closest = newClosest;
break;
}
}
closestDifferences = winnerSoFar;
return closest;
}
开发者ID:tapicer,项目名称:resource-contracts-.net,代码行数:59,代码来源:Comparer.cs
示例19: ProcessProperties
private void ProcessProperties(BlockList small_blocks,
BlockList big_blocks,
IEnumerator properties,
DirectoryNode dir,
int headerPropertiesStartAt)
{
while (properties.MoveNext())
{
Property property = ( Property ) properties.Current;
String name = property.Name;
DirectoryNode parent = (dir == null)
? (( DirectoryNode ) this.Root)
: dir;
if (property.IsDirectory)
{
DirectoryNode new_dir =
( DirectoryNode ) parent.CreateDirectory(name);
new_dir.StorageClsid=property.StorageClsid ;
ProcessProperties(
small_blocks, big_blocks,
((DirectoryProperty)property).Children, new_dir, headerPropertiesStartAt);
}
else
{
int startBlock = property.StartBlock;
int size = property.Size;
POIFSDocument document = null;
if (property.ShouldUseSmallBlocks)
{
document =
new POIFSDocument(name, small_blocks
.FetchBlocks(startBlock, headerPropertiesStartAt), size);
}
else
{
document =
new POIFSDocument(name,
big_blocks.FetchBlocks(startBlock,headerPropertiesStartAt),
size);
}
parent.CreateDocument(document);
}
}
}
开发者ID:89sos98,项目名称:npoi,代码行数:48,代码来源:POIFSFileSystem.cs
示例20: VisitBlockList
public virtual BlockList VisitBlockList(BlockList blockList1, BlockList blockList2)
{
if (blockList1 == null) return null;
for (int i = 0, n = blockList1.Count, m = blockList2 == null ? 0 : blockList2.Count; i < n; i++)
{
//^ assert blockList2 != null;
if (i >= m)
blockList1[i] = this.VisitBlock(blockList1[i], null);
else
blockList1[i] = this.VisitBlock(blockList1[i], blockList2[i]);
}
return blockList1;
}
开发者ID:hnlshzx,项目名称:DotNetOpenAuth,代码行数:13,代码来源:DoubleVisitor.cs
注:本文中的BlockList类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论