inserts a new rule.

@param rule the rule to insert
@param index the insert pos
@throws DOMException in case of error
195922
public void insertRule(final String rule, final int index) throws DOMException {
        try {
            final CSSOMParser parser = new CSSOMParser();
            parser.setParentStyleSheet(this);
            parser.setErrorHandler(ThrowCssExceptionErrorHandler.INSTANCE);
            final AbstractCSSRuleImpl r = parser.parseRule(rule);

            if (r == null) {
                // this should neven happen because of the ThrowCssExceptionErrorHandler
                throw new DOMExceptionImpl(
                        DOMException.SYNTAX_ERR,
                        DOMExceptionImpl.SYNTAX_ERROR,
                        "Parsing rule '" + rule + "' failed.");
            }

            if (getCssRules().getLength() > 0) {
                // We need to check that this type of rule can legally go into
                // the requested position.
                int msg = -1;
                if (r instanceof CSSCharsetRuleImpl) {

                    // Index must be 0, and there can be only one charset rule
                    if (index != 0) {
                        msg = DOMExceptionImpl.CHARSET_NOT_FIRST;
                    }
                    else if (getCssRules().getRules().get(0) instanceof CSSCharsetRuleImpl) {
                        msg = DOMExceptionImpl.CHARSET_NOT_UNIQUE;
                    }
                }
                else if (r instanceof CSSImportRuleImpl) {
                    // Import rules must preceed all other rules (except
                    // charset rules)
                    if (index <= getCssRules().getLength()) {
                        for (int i = 0; i < index; i++) {
                            final AbstractCSSRuleImpl ri = getCssRules().getRules().get(i);
                            if (!(ri instanceof CSSCharsetRuleImpl) && !(ri instanceof CSSImportRuleImpl)) {
                                msg = DOMExceptionImpl.IMPORT_NOT_FIRST;
                                break;
                            }
                        }
                    }
                }
                else {
                    if (index <= getCssRules().getLength()) {
                        for (int i = index; i < getCssRules().getLength(); i++) {
                            final AbstractCSSRuleImpl ri = getCssRules().getRules().get(i);
                            if ((ri instanceof CSSCharsetRuleImpl) || (ri instanceof CSSImportRuleImpl)) {
                                msg = DOMExceptionImpl.INSERT_BEFORE_IMPORT;
                                break;
                            }
                        }
                    }
                }
                if (msg > -1) {
                    throw new DOMExceptionImpl(DOMException.HIERARCHY_REQUEST_ERR, msg);
                }
            }

            // Insert the rule into the list of rules
            getCssRules().insert(r, index);

        }
        catch (final IndexOutOfBoundsException e) {
            throw new DOMExceptionImpl(
                DOMException.INDEX_SIZE_ERR,
                DOMExceptionImpl.INDEX_OUT_OF_BOUNDS,
                e.getMessage());
        }
        catch (final CSSException e) {
            throw new DOMExceptionImpl(
                DOMException.SYNTAX_ERR,
                DOMExceptionImpl.SYNTAX_ERROR,
                e.getMessage());
        }
        catch (final IOException e) {
            throw new DOMExceptionImpl(
                DOMException.SYNTAX_ERR,
                DOMExceptionImpl.SYNTAX_ERROR,
                e.getMessage());
        }
    }
885387
private final void insert(Object x) {
        buffer[putIndex] = x;

        if (++putIndex >= buffer.length) {
            putIndex = 0;
        }
    }
888302
function (sheet, selector, rule) {
            var index;
            if (sheet.insertRule) {
                return sheet.insertRule(selector + '{' + rule + '}', sheet.cssRules.length);
            } else {
                index = sheet.addRule(selector, rule, sheet.rules.length);
                if (index < 0) {
                    index = sheet.rules.length - 1;
                }
                return index;
            }
        }
1280318
public function addRuleToAll(ValidatorRule $rule, $position = self::APPEND) {
    if ($position == self::APPEND) {
      foreach ($this->rules as $key => $NULL) {
        array_push($this->rules[$key],$rule);
      }
    }
    
    if ($position == self::PREPEND) {
      foreach ($this->rules as $key => $NULL) {
        array_unshift($this->rules[$key], $rule);
      }
    }
    
    if (is_numeric($position)) {
      foreach ($this->rules as $key => $NULL) {
        A::insert($this->rules[$key], $rule, (int) $position);
      }
    }
    
    throw new \Psc\Exception('unbekanter Parameter für position: '.Code::getInfo($position));
  }
532929
public void setRules(java.util.Collection<TopicRuleListItem> rules) {
        if (rules == null) {
            this.rules = null;
            return;
        }

        this.rules = new java.util.ArrayList<TopicRuleListItem>(rules);
    }
963473
public void updateRuleIndexByBodyPredicate(CQIE rule) {
		for (Function bodyAtom : rule.getBody()) {

			if (bodyAtom.isDataFunction()) {
				Predicate functionSymbol = bodyAtom.getFunctionSymbol();
				if (!ruleIndexByBodyPredicate.containsEntry(functionSymbol, rule)){
					ruleIndexByBodyPredicate.put(functionSymbol, rule);
				}
			} else if (bodyAtom.isAlgebraFunction() || bodyAtom.isOperation()) {
				updateRuleIndexByBodyPredicate_traverseBodyAtom(rule, bodyAtom);
			// BC: should we reintroduce arithmetic functions?
			//} else if (bodyAtom.isArithmeticFunction() || bodyAtom.isDataTypeFunction()){
			} else if (bodyAtom.isDataTypeFunction()){
				continue;
			} else {
				throw new IllegalStateException("Unknown Function");
			}
		}
	}
695927
def insert( index, *args)
      if !args.nil?
        pos = index
        args.each do |url| 
          convert = convert_remote_url( url )
          super( pos, convert )
          if index >= 0
            pos = pos + 1          
          end
        end
      else
        super( index, nil )  
      end
    end
1114569
public void addRule(TransliterationRule rule) {
        ruleVector.add(rule);
        int len;
        if ((len = rule.getAnteContextLength()) > maxContextLength) {
            maxContextLength = len;
        }

        rules = null;
    }
723736
public void addAttribute(int index, VertexAttribute attribute) {
        attributes.put(index, attribute);
        nameToIndex.put(attribute.getName(), index);
    }
437397
private void insertAfterEdge(Geometry geom, GeometryIndex index, Coordinate coordinate)
			throws GeometryIndexNotFoundException {
		// First we check the geometry type:
		if (!Geometry.LINE_STRING.equals(geom.getGeometryType())
				&& !Geometry.LINEAR_RING.equals(geom.getGeometryType())) {
			throw new GeometryIndexNotFoundException("Could not match index with given geometry.");
		}
		if (index.getValue() < 0) {
			throw new GeometryIndexNotFoundException("Cannot insert in a negative index.");
		}

		// Then we check if the edge exists:
		if (geom.getCoordinates() != null && geom.getCoordinates().length > index.getValue() + 1) {
			// Inserting on edges allows only to insert on existing edges. No adding at the end:
			Coordinate[] result = new Coordinate[geom.getCoordinates().length + 1];
			int count = 0;
			for (int i = 0; i < geom.getCoordinates().length; i++) {
				if (i == (index.getValue() + 1)) {
					result[i] = coordinate;
					count++;
				}
				result[i + count] = geom.getCoordinates()[i];
			}
			geom.setCoordinates(result);
		} else {
			throw new GeometryIndexNotFoundException("Cannot insert a vertex into an edge that does not exist.");
		}
	}
792058
public void insertAttributeValue(String attributeName, String value, int index) {

        if (m_simpleAttributes.containsKey(attributeName)) {
            m_simpleAttributes.get(attributeName).add(index, value);
        } else {
            setAttributeValue(attributeName, value);
        }
        fireChange();
    }
769763
function ( child, index ) {
            var el = this.element();
            if ( typeof index === 'number' ) {
                var children = el.children,
                    childNum = children.length;
    
                if ( childNum > 0 && index < childNum ) {
                    el.insertBefore( child, children[index] );
                    return;
                }
            }
            el.appendChild( child );
        }
705478
public void add(int index, double element)
    {
        if(index == size())//special case, just appending
        {
            add(element);
        }
        else
        {
            boundsCheck(index);
            enlageIfNeeded(1);
            System.arraycopy(array, index, array, index+1, size()-index);
            set(index, element);
            increasedSize(1);
        }
    }
224741
def insert(index, value)
      index = validate_index_range(index)

      if index < @entry_counter
        # Insert in between existing elements
        @store.transaction do
          @root.insert(index, value)
          self.entry_counter += 1
        end
      else
        self[index] = value
      end
    end
1261646
def insert(self, index: int, obj: Any) -> None:
        
        if obj is not None:
            super().insert(index, obj)
1244638
public void addRule(Rule r) {
		rules.add(r);
		FuzzyActivity head = (FuzzyActivity) solver.createVariable(r
				.getComponent().getName());
		head.setMarking(markings.UNJUSTIFIED);
		head.setDomain(r.getComponent().getStates(), r.getPossibilities());
		ruleHeads.put(head, r);
		// fan.addVariable(head);
		fas.add(head);
		groundActivity.add(head);
		heads.add(head);
	}
912180
def insert_pattern(self, pattern, index):
        

        LOGGER.debug("> Inserting '{0}' at '{1}' index.".format(pattern, index))

        self.remove_pattern(pattern)

        self.beginInsertRows(self.get_node_index(self.root_node), index, index)
        pattern_node = PatternNode(name=pattern)
        self.root_node.insert_child(pattern_node, index)
        self.endInsertRows()
        self.pattern_inserted.emit(pattern_node)
        return True