gnu.trove.TIntArrayList.insert()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(4.3k)|赞(0)|评价(0)|浏览(144)

本文整理了Java中gnu.trove.TIntArrayList.insert()方法的一些代码示例,展示了TIntArrayList.insert()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TIntArrayList.insert()方法的具体详情如下:
包路径:gnu.trove.TIntArrayList
类名称:TIntArrayList
方法名:insert

TIntArrayList.insert介绍

[英]See gnu.trove.list.array.TIntArrayList#insert(int,int)
[中]见gnu。宝藏。列表大堆TIntArrayList#插入(int,int)

代码示例

代码示例来源:origin: de.julielab/jcore-mallet-0.4

/**
 * Inserts the array of <tt>values</tt> into the list at
 * <tt>offset</tt>.  All values including and to the right of
 * <tt>offset</tt> are shifted to the right.
 *
 * @param offset an <code>int</code> value
 * @param values an <code>int[]</code> value
 */
public void insert(int offset, int[] values) {
  insert(offset, values, 0, values.length);
}

代码示例来源:origin: terrier-org/terrier-core

/** Returns true iff we did not already have a posting for this document */
public boolean addOrUpdateFreq(int docid, int freq) {
  int index = pl_doc.binarySearch(docid);
  if (index >= 0)
  {
    pl_freq.setQuick(index, freq + pl_freq.get(index));    
    return false;
  } else {
    pl_doc.insert( -(index +1), docid);
    pl_freq.insert( -(index +1), freq);	
    return true;
  }
  
}

代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-common

protected void internalAdd(final int _i, final int _v) {
 if (_i == list_.size()) {
  list_.add(_v);
 } else {
  list_.insert(_i, _v);
 }
}

代码示例来源:origin: jatecs/jatecs

public void setDocumentFeatureFrequency(int document, int feature,
                    int frequency) {
  if (feature >= 0) {
    int size = _contentDB._featuresDocuments.size();
    if (feature >= size) {
      for (int i = size; i <= feature; ++i) {
        _contentDB._featuresDocuments.add(new TIntArrayList());
        _contentDB._featuresFrequencies.add(new TIntArrayList());
      }
    }
    if (document >= 0) {
      TIntArrayList docs = _contentDB._featuresDocuments.get(feature);
      TIntArrayList freqs = _contentDB._featuresFrequencies
          .get(feature);
      int pos = docs.binarySearch(document);
      if (pos < 0 && frequency > 0) {
        pos = -pos - 1;
        docs.insert(pos, document);
        freqs.insert(pos, frequency);
      } else {
        if (frequency > 0) {
          freqs.setQuick(pos, frequency);
        } else {
          docs.remove(pos);
          freqs.remove(pos);
        }
      }
    }
  }
}

代码示例来源:origin: jatecs/jatecs

public void setDocumentFeatureFrequency(int document, int feature, int frequency) {
  if (document >= 0) {
    int size = _contentDB._documentsFeatures.size();
    if (document >= size) {
      for (int i = size; i <= document; ++i) {
        _contentDB._documentsFeatures.add(new TIntArrayList());
        _contentDB._documentsFrequencies.add(new TIntArrayList());
      }
    }
    if (feature >= 0) {
      TIntArrayList feats = _contentDB._documentsFeatures.get(document);
      TIntArrayList freqs = _contentDB._documentsFrequencies.get(document);
      int pos = feats.binarySearch(feature);
      if (pos < 0 && frequency > 0) {
        pos = -pos - 1;
        feats.insert(pos, feature);
        freqs.insert(pos, frequency);
      } else {
        if (frequency > 0) {
          freqs.setQuick(pos, frequency);
        } else {
          feats.remove(pos);
          freqs.remove(pos);
        }
      }
    }
  }
}

代码示例来源:origin: jatecs/jatecs

protected void addCategoryHierarchicaly(int document, short category, boolean primary) {
  TIntArrayList docs = _classificationDB._categoriesDocuments.get(category);
  Vector<Boolean> docsPrimary = _classificationDB._categoriesDocumentsPrimary.get(category);
  int pos = docs.binarySearch(document);
  if (pos < 0) {
    docs.insert(-pos - 1, document);
    docsPrimary.insertElementAt(primary, -pos - 1);
  } else {
    if (primary) {
      docsPrimary.set(pos, true);
    }
  }
  IShortIterator parents = _classificationDB.getCategoryDB().getParentCategories(category);
  while (parents.hasNext())
    addCategoryHierarchicaly(document, parents.next(), primary);
}

代码示例来源:origin: jatecs/jatecs

if (pos < 0 && frequency > 0) {
  pos = -pos - 1;
  feats.insert(pos, feature);
  freqs.insert(pos, frequency);
} else {
  if (frequency > 0) {
if (pos < 0 && frequency > 0) {
  pos = -pos - 1;
  docs.insert(pos, document);
  freqs.insert(pos, frequency);
} else {
  if (frequency > 0) {

代码示例来源:origin: jatecs/jatecs

protected void addCategoryHierarchicaly(int document, short category, boolean primary) {
  TShortArrayList cats = _classificationDB._documentsCategories.get(document);
  Vector<Boolean> catsPrimary = _classificationDB._documentsCatsPrimary.get(document);
  int pos = cats.binarySearch(category);
  if (pos < 0) {
    cats.insert(-pos - 1, category);
    catsPrimary.insertElementAt(primary, -pos - 1);
  } else {
    if (primary) {
      catsPrimary.set(pos, true);
    }
  }
  TIntArrayList docs = _classificationDB._categoriesDocuments.get(category);
  pos = docs.binarySearch(document);
  if (pos < 0) {
    docs.insert(-pos - 1, document);
  }
  IShortIterator parents = _classificationDB.getCategoryDB().getParentCategories(category);
  while (parents.hasNext())
    addCategoryHierarchicaly(document, parents.next(), primary);
}

相关文章