public void AppendMorphoFormEndings(BaseMorphoFormNative other) { Debug.Assert(_MorphoFormEndings[0] == other._MorphoFormEndings[0], "_MorphoFormEndings[ 0 ] != baseMorphoForms._MorphoFormEndings[ 0 ]"); //select longest array of morpho-form-endings char *[] first, second; if (_MorphoFormEndings.Length < other._MorphoFormEndings.Length) { first = other._MorphoFormEndings; second = _MorphoFormEndings; } else { first = _MorphoFormEndings; second = other._MorphoFormEndings; } fixed(char **morphoFormEndingsBase = first) { for (int i = 0, len = first.Length; i < len; i++) { _TempBufferHS.Add(new IntPtr(*(morphoFormEndingsBase + i))); } } //store curreent count in 'tempBufferHS' var count = _TempBufferHS.Count; fixed(char **morphoFormEndingsBase = second) { for (int i = 0, len = second.Length; i < len; i++) { _TempBufferHS.Add(new IntPtr(*(morphoFormEndingsBase + i))); } } //if count of 'tempBufferHS' not changed, then [_MorphoFormEndings] & [other._MorphoFormEndings] are equals if (count != _TempBufferHS.Count) { _MorphoFormEndings = new char *[_TempBufferHS.Count]; fixed(char **morphoFormEndingsBase = _MorphoFormEndings) { var it = _TempBufferHS.GetEnumerator(); for (var i = 0; it.MoveNext(); i++) { *(morphoFormEndingsBase + i) = (char *)it.Current; } } } _TempBufferHS.Clear(); }
internal void SetMorphoForms(List <MorphoFormNative> morphoForms) { if (morphoForms.Count != 0) { //---_MorphoForms = morphoForms.ToArray(); LinkedList <MorphoAttributeEnum> morphoAttributes = null; for (int i = 0, len = morphoForms.Count; i < len; i++) { var morphoForm = morphoForms[i]; #region [.окончания морфо-форм.] _TempBufferSet.Add((IntPtr)morphoForm.Ending); #endregion #region [.MorphoFormEndingUpper-&-MorphoAttribute.] var endingUpperPtr = (IntPtr)morphoForm.EndingUpper; if (!_TempBufferSetLiists.TryGetValue(endingUpperPtr, ref morphoAttributes)) { morphoAttributes = PopLinkedList(); _TempBufferSetLiists.Add(endingUpperPtr, morphoAttributes); } var morphoAttribute = MorphoAttributePair.GetMorphoAttribute(this, morphoForm); morphoAttributes.AddLast(morphoAttribute); #endregion } #region [.окончания морфо-форм.] _MorphoFormEndings = new char *[_TempBufferSet.Count]; fixed(char **morphoFormEndingsBase = _MorphoFormEndings) { var it = _TempBufferSet.GetEnumerator(); for (var i = 0; it.MoveNext(); i++) { *(morphoFormEndingsBase + i) = (char *)it.Current; } #region commented. foreach. /*var i = 0; * foreach ( var intptr in tempBufferHS ) * { *(morphoFormEndingsBase + i++) = (char*) intptr; * }*/ #endregion } _TempBufferSet.Clear(); #endregion #region [.MorphoFormEndingUpper-&-MorphoAttribute.] _MorphoFormEndingUpperAndMorphoAttributes = new MorphoFormEndingUpperAndMorphoAttribute[_TempBufferSetLiists.Count]; var it2 = _TempBufferSetLiists.GetEnumerator(); for (var i = 0; it2.MoveNext(); i++) { _MorphoFormEndingUpperAndMorphoAttributes[i] = new MorphoFormEndingUpperAndMorphoAttribute( it2.Current_IntPtr, it2.Current_Value); PushLinkedList(it2.Current_Value); } #region commented /* * var k = 0; * foreach ( var p in tempBufferDict ) * { * _MorphoFormEndingUpperAndMorphoAttributes[ k++ ] = new MorphoFormEndingUpperAndMorphoAttribute( p.Key, p.Value.ToArray() ); * PushLinkedList( p.Value ); * } */ #endregion _TempBufferSetLiists.Clear(); #endregion } else { //_MorphoForms = EMPTY_MORPHOFORM; _MorphoFormEndings = EMPTY_ENDINGS; _MorphoFormEndingUpperAndMorphoAttributes = EMPTY_MFUEMA; } }